1
當單擊列表中的項目,一個ng-click
火災與該項目的id
發,當時的想法是去匹配id
該項目的description
但它似乎只採摘請改爲使用該項目的index
。AngularJS從項目獲取數據,其中
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $http) {
$scope.name = 'World';
$http.get('tasks.json').success(function(data) {
$scope.tasks = data.item;
console.log($scope.tasks);
});
$scope.viewTask = function(id) {
console.log(id);
console.log($scope.tasks[id].description); //The Description to go with the ID.
};
});
我去了這 var found = $ filter('filter')($ scope.tasks,{id:task_id},true); \t \t \t \t if(found.length){found [0] .description; }' – ngplayground
做驗證是個好主意。 – lucuma