【发布时间】:2014-08-19 20:50:20
【问题描述】:
Plunker 链接:http://plnkr.co/edit/j7BeL72lwHISCIlwuAez?p=preview
在上面的链接中,我使用 $scope 来传递数据。但我想使用模型方法并将 MainController 中的 $scope.data 替换为 this.data
var app = angular.module('plunker', []);
app.controller('MainCtrl', ['$scope',
function($scope) {
$scope.data = [{
time: '8/19/2014',
id: 123,
text: 'first'
}, {
time: '8/18/2014',
id: 456,
text: 'second'
}, {
time: '8/17/2014',
id: 123,
text: 'third'
}];
}
]);
app.directive('scrollGrid', [
function() {
return {
restrict: 'AE',
scope: {
data: '='
},
templateUrl: 'mainScroll.html',
controller: 'gridController',
controllerAs: 'gridCtrl'
}
}
]);
app.controller('gridController', ['$scope',
function($scope) {}
])
【问题讨论】:
标签: angularjs angularjs-directive