var app = angular.module('app', []);
app.directive('myGridTable', function($http) {
return {
restrict: 'AE',
link: function(scope, element, attrib) {
$http.get(attrib.src).success(function(response) {
scope.rows = response.data;
});
console.log("message from directive");
angular.forEach(scope.rows, function(value, key) {
console.log(key);
});
}
};
});
答案 0 :(得分:2)
您正在回访之外访问回复。
让你的循环成功。
试试这个
$http.get(attrib.src).success(function(response) {
scope.rows = response.data;
console.log("message from directive");
angular.forEach(scope.rows, function(value, key) {
console.log(key);
});
});