ace-angular
Advanced tools
Comparing version 0.0.1 to 0.1.0
'use strict'; | ||
/** | ||
* Module | ||
* Module ace.angular | ||
* | ||
* Description | ||
* Description to use Ace Editor in angular JS | ||
*/ | ||
@@ -21,5 +21,42 @@ angular.module('ace.angular',[]) | ||
var options = scope.$eval(attrs.aceEditor) || {}; | ||
if(options.mode){ | ||
session.setMode("ace/mode/"+options.mode); | ||
} | ||
if(options.require){ | ||
for(var i in options.require){ | ||
window.ace.require(options.require[i]); | ||
} | ||
} | ||
if (options.theme) { | ||
editor.setTheme("ace/theme/"+options.theme); | ||
} | ||
if (options.advanced) { | ||
editor.setOptions(options.advanced); | ||
} | ||
if(options.onLoad){ | ||
options.onLoad(editor, session, window.ace); | ||
} | ||
elm.on('$destroy', function () { | ||
editor.session.$stopWorker(); | ||
editor.destroy(); | ||
}); | ||
scope.$watch(function() { | ||
return [elm[0].offsetWidth, elm[0].offsetHeight]; | ||
}, function() { | ||
editor.resize(); | ||
editor.renderer.updateFull(); | ||
}, true); | ||
session.on("change", function(e){ | ||
ngModel.$setViewValue(session.getValue()); | ||
}); | ||
} | ||
@@ -26,0 +63,0 @@ } |
@@ -7,2 +7,17 @@ var app = angular.module('app_test',['ace.angular']); | ||
} | ||
$scope.aceOptions = { | ||
mode: 'sql', | ||
theme:'sqlserver', | ||
require: ["ace/ext/language_tools"], | ||
advanced:{ | ||
enableBasicAutocompletion: true, | ||
enableSnippets: true, | ||
enableLiveAutocompletion: false, | ||
autoScrollEditorIntoView: true, | ||
}, | ||
onLoad: function(editor, session, ace){ | ||
$scope.langTools = ace.require("ace/ext/language_tools"); | ||
} | ||
} | ||
}]) |
{ | ||
"name": "ace-angular", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Module to use ace editor in angular js", | ||
@@ -5,0 +5,0 @@ "main": "ace-angular.js", |
# ace-angular | ||
Using Ace Editor in AngularJS | ||
## Requeriments | ||
- AngularJS: npm install angular | ||
- Ace Builds: npm install ace-builds | ||
## Install | ||
``` | ||
npm install ace-angular | ||
``` | ||
## Usage | ||
```html | ||
<!-- Load Angular --> | ||
<script src="node_modules/angular/angular.js"></script> | ||
<!-- load ace --> | ||
<script src="node_modules/ace-builds/src-min/ace.js"></script> | ||
<!-- load ace language tools --> | ||
<script src="node_modules/ace-builds/src-min/ext-language_tools.js"></script> | ||
<!-- load ace-angular --> | ||
<script src="node_modules/ace-angular/ace-angular.js"></script> | ||
``` | ||
Create angular module | ||
```js | ||
var app = angular.module('myapp',['ace.angular']); | ||
``` | ||
Using directive | ||
```html | ||
<div ace-editor="aceOptions" ng-model="aceContent"></div> | ||
``` | ||
Controller | ||
```js | ||
$scope.aceOptions = { | ||
method: 'sql', | ||
theme: 'sqlserver', | ||
onLoad: function(editor, session, ace){ | ||
// do anythig | ||
} | ||
} | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5943
70
42