2
我有通过这个复杂的对象阵列通过以一个指令的属性的麻烦。我做错了什么,为什么错了?角JS和传递复杂对象数组作为属性来指示
剪切和粘贴代码
<div ng-controller="MyCtrl">
<pass-object obj="obj"></pass-object>
</div>
var myApp = angular.module('myApp',[]);
myApp.directive('passObject', function() {
return {
restrict: 'E',
scope: { obj: '=' },
template: '<div ng-repeat="foo in foos">Hello, {{foo.prop}}!</div></div>'
};
});
myApp.controller('MyCtrl', function ($scope) {
$scope.obj = [{ prop: "hello" }, {prop: "world"}];
});