Reputation: 31237
I was trying to initialize and fetch the array values from the controller.
The fiddle is here.
var app = angular.module('carApp', []);
app.controller('carAppCtrlr', function ($scope) {
$scope.vehicles = [{
type: 'car',
color: 'red'
}, {
type: 'bike',
color: 'black'
}];
};);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div data-ng-app='carApp' data-ng-controller='carAppCtrlr'>
<ul>
<li data-ng-repeat='v in vehicles'>{{v.type +" " + v.color}}</li>
</ul>
</div>
The values are not getting printed:
Upvotes: 1
Views: 346
Reputation: 1300
delete semicolon in last line of your controller definition
var app = angular.module('carApp', []);
app.controller('carAppCtrlr', function ($scope) {
$scope.vehicles = [{
type: 'car',
color: 'red'
}, {
type: 'bike',
color: 'black'
}];
});
Upvotes: 3