Unified
Split
Showing
with
8 additions
and 10 deletions.
- +6 −7 src/ng/compile.js
- +2 −3 test/ng/compileSpec.js
| @@ -942,7 +942,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | ||
| * registered controller} if passed as a string. An empty `noop` function by default. | ||
| * - `controllerAs` – `{string=}` – identifier name for to reference the controller in the component's scope. | ||
| * If present, the controller will be published to scope under the `controllerAs` name. | ||
| * If not present, this will default to be the same as the component name. | ||
| * If not present, this will default to be `$ctrl`. | ||
| * - `template` – `{string=|function()=}` – html template as a string or a function that | ||
| * returns an html template as a string which should be used as the contents of this component. | ||
| * Empty string by default. | ||
| @@ -967,7 +967,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | ||
| * See {@link ng.$compile#-bindtocontroller- `bindToController`}. | ||
| * - `transclude` – `{boolean=}` – whether {@link $compile#transclusion content transclusion} is enabled. | ||
| * Disabled by default. | ||
| * - `isolate` – `{boolean=}` – whether the new scope is isolated. Isolated by default. | ||
| * - `restrict` - `{string=}` - a string containing one or more characters from {@link ng.$compile#-restrict- EACM}, | ||
| * which restricts the component to specific directive declaration style. If omitted, this defaults to 'E'. | ||
| * - `$canActivate` – `{function()=}` – TBD. | ||
| @@ -982,21 +981,21 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | ||
| * directives. Component definitions usually consist only of a template and a controller backing it. | ||
| * | ||
| * In order to make the definition easier, components enforce best practices like use of `controllerAs`, | ||
| * `bindToController` and default behaviors like **isolate scope** and restriction to elements. | ||
| * `bindToController`, **isolate scope** and default behaviors like restriction to elements. | ||
| * | ||
| * Here are a few examples of how you would usually define components: | ||
| * | ||
| * ```js | ||
| * var myMod = angular.module(...); | ||
| * myMod.component('myComp', { | ||
| * template: '<div>My name is {{myComp.name}}</div>', | ||
| * template: '<div>My name is {{$ctrl.name}}</div>', | ||
| * controller: function() { | ||
| * this.name = 'shahar'; | ||
| * } | ||
| * }); | ||
| * | ||
| * myMod.component('myComp', { | ||
| * template: '<div>My name is {{myComp.name}}</div>', | ||
| * template: '<div>My name is {{$ctrl.name}}</div>', | ||
| * bindings: {name: '@'} | ||
| * }); | ||
| * | ||
| @@ -1067,11 +1066,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | ||
| var template = (!options.template && !options.templateUrl ? '' : options.template); | ||
| return { | ||
| controller: options.controller || function() {}, | ||
| controllerAs: identifierForController(options.controller) || options.controllerAs || name, | ||
| controllerAs: identifierForController(options.controller) || options.controllerAs || '$ctrl', | ||
| template: makeInjectable(template), | ||
| templateUrl: makeInjectable(options.templateUrl), | ||
| transclude: options.transclude, | ||
| scope: options.isolate === false ? true : {}, | ||
| scope: {}, | ||
| bindToController: options.bindings || {}, | ||
| restrict: options.restrict || 'E' | ||
| }; | ||
| @@ -9333,7 +9333,7 @@ describe('$compile', function() { | ||
| inject(function(myComponentDirective) { | ||
| expect(myComponentDirective[0]).toEqual(jasmine.objectContaining({ | ||
| controller: jasmine.any(Function), | ||
| controllerAs: 'myComponent', | ||
| controllerAs: '$ctrl', | ||
| template: '', | ||
| templateUrl: undefined, | ||
| transclude: undefined, | ||
| @@ -9352,7 +9352,6 @@ describe('$compile', function() { | ||
| template: 'abc', | ||
| templateUrl: 'def.html', | ||
| transclude: true, | ||
| isolate: false, | ||
| bindings: {abc: '='}, | ||
| restrict: 'EA' | ||
| }); | ||
| @@ -9364,7 +9363,7 @@ describe('$compile', function() { | ||
| template: 'abc', | ||
| templateUrl: 'def.html', | ||
| transclude: true, | ||
| scope: true, | ||
| scope: {}, | ||
| bindToController: {abc: '='}, | ||
| restrict: 'EA' | ||
| })); | ||