2012-03-08 23:00:38 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc directive
|
2012-06-12 06:49:24 +00:00
|
|
|
* @name ng.directive:ngInit
|
2013-09-08 21:22:54 +00:00
|
|
|
* @restrict AC
|
2012-03-08 23:00:38 +00:00
|
|
|
*
|
|
|
|
|
* @description
|
2012-04-06 23:35:17 +00:00
|
|
|
* The `ngInit` directive specifies initialization tasks to be executed
|
2012-03-08 23:00:38 +00:00
|
|
|
* before the template enters execution mode during bootstrap.
|
|
|
|
|
*
|
|
|
|
|
* @element ANY
|
2012-05-24 21:49:47 +00:00
|
|
|
* @param {expression} ngInit {@link guide/expression Expression} to eval.
|
2012-03-08 23:00:38 +00:00
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
<doc:example>
|
|
|
|
|
<doc:source>
|
2012-03-09 08:00:05 +00:00
|
|
|
<div ng-init="greeting='Hello'; person='World'">
|
2012-03-08 23:00:38 +00:00
|
|
|
{{greeting}} {{person}}!
|
|
|
|
|
</div>
|
|
|
|
|
</doc:source>
|
|
|
|
|
<doc:scenario>
|
|
|
|
|
it('should check greeting', function() {
|
|
|
|
|
expect(binding('greeting')).toBe('Hello');
|
|
|
|
|
expect(binding('person')).toBe('World');
|
|
|
|
|
});
|
|
|
|
|
</doc:scenario>
|
|
|
|
|
</doc:example>
|
|
|
|
|
*/
|
|
|
|
|
var ngInitDirective = ngDirective({
|
|
|
|
|
compile: function() {
|
|
|
|
|
return {
|
|
|
|
|
pre: function(scope, element, attrs) {
|
|
|
|
|
scope.$eval(attrs.ngInit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|