0
我有對dataSourceModel範圍可變2路結合一個指令,但由於某種原因,它是示出了在指令爲未定義。我在這裏做錯了什麼?爲什麼不是這個領域我的指令綁定?
Plunker:http://plnkr.co/edit/LxWMbY9qtDSBUPWNqWV7?p=preview
代碼:
HTML:
<div ng-controller='TestCtrl'>
<test-directive
selected-id='selectedId'
data-source-model='workOrderItems'> <!-- This does not work -->
</test-directive>
{{workOrderItems}} <!-- this works -->
</div>
腳本:
var app = angular.module("testApp", []);
app.controller('TestCtrl', ['$scope', function ($scope) {
$scope.workOrderItems = 'abcd';
$scope.selectedId = '123';
}]);
app.directive('testDirective',function() {
return {
restrict: 'E',
scope: {
selectedId: '=',
dataSourceModel: '='
},
replace: true,
template: "<div></div>",
link: function (scope, element, attrs) {
console.log(scope.selectedId, scope.dataSourceModel);
}
}
});
哇。現在很明顯,你指出了...... – Scottie 2014-12-02 21:09:17