Another Example
In the next example, we will create a new controller file.
angular.module(‘myApp’, []).controller(‘namesCtrl’, function($scope) { $scope.names = [ {name:’Jani’,country:’Norway’}, {name:’Hege’,country:’Sweden’}, {name:’Kai’,country:’Denmark’} ]; }); |
Then, we will utilize the controller file within an application.
<div ng-app=”myApp” ng-controller=”namesCtrl”> <ul> <li ng-repeat=”x in names”> {{ x.name + ‘, ‘ + x.country }} </li> </ul> </div> <script src=”namesController.js”></script> |