Friday, 15 June 2012

arrays - AngularJS Scope don't call elements -



arrays - AngularJS Scope don't call elements -

hi guys exercise scopes don't run,

view:

<body ng-controller="marcascontroller"> <ul> <li ng-repeat="todo in marcas"> {{todo.nombre}} <ul> <li ng-repeat="tipo in todo.modelo">{{tipo.nombre}}</li> </ul> </li> </ul> </body>

controller:

app.controller('marcascontroller', ['$scope', function($scope) { $scope.marcas = [{ "marcas": [ { "marca": "chevrolet", "modelo": [ { "nombre": "aveo", "image": "images/aveo.jpg", "modelo": "2000-2014", "tab": "aveo" }, { "nombre": "captiva", "image": "images/captiva.jpg", "modelo": "2000-2014", "tab": "captiva" } ] } ] }]; }]) example

please how utilize scopes phone call objects

given info construction should doing this:

<ul> <li ng-repeat="todo in marcas[0].marcas"> {{todo.marca}} <ul> <li ng-repeat="tipo in todo.modelo">{{tipo.nombre}}</li> </ul> </li> </ul> example

notice $scope.marcas array of objects contains 1 element, element has 1 attribute: marcas array...

maybe wanted info construction instead:

$scope.marcas =[ { "marca": "chevrolet", "modelo": [ { "nombre": "aveo", "image": "images/aveo.jpg", "modelo": "2000-2014", "tab": "aveo" }, { "nombre": "captiva", "image": "images/captiva.jpg", "modelo": "2000-2014", "tab": "captiva" } ] } ];

in case, right syntax view be:

<ul> <li ng-repeat="todo in marcas"> {{todo.marca}} <ul> <li ng-repeat="tipo in todo.modelo">{{tipo.nombre}}</li> </ul> </li> </ul> example

arrays angularjs scope angularjs-scope angularjs-ng-repeat

No comments:

Post a Comment