1

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>

Output

The values are not getting printed:

output

1 Answer 1

3

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'
   }];
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Ashot - so quick and prefect! Just updated the fiddle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.