Ng-init is a local scope of DOM controller in the region. In the ng-init blog is declare a variable, This variable have to scope of current Controller.
Syntax:
<div ng-init="variable">
</div>
Example:
<div ng-app="appInit">
<div ng-controller="appCtrl">
<div ng-init="items = (data | orderBy:'name')">
<div ng-repeat="item in items">
{{item.name}} - {{item.mobile}}
</div>
</div>
</div>
</div>
AngularJS:
var app = angular.module('appInit',[]);
app.controller('appCtrl',function($scope){
$scope.data = [
{name:'sathiya',mobile:'9865988754'},
{name:'rajesh',mobile:'9887879856'}, {name:'mani',mobile:'5487548754'}
];
});
Result:
Demo
Syntax:
<div ng-init="variable">
</div>
Example:
<div ng-app="appInit">
<div ng-controller="appCtrl">
<div ng-init="items = (data | orderBy:'name')">
<div ng-repeat="item in items">
{{item.name}} - {{item.mobile}}
</div>
</div>
</div>
</div>
AngularJS:
var app = angular.module('appInit',[]);
app.controller('appCtrl',function($scope){
$scope.data = [
{name:'sathiya',mobile:'9865988754'},
{name:'rajesh',mobile:'9887879856'}, {name:'mani',mobile:'5487548754'}
];
});
Result:
Demo
Comments
Post a Comment