所以我认为:
<tr ng-repeat="currentRow in rowsToRender">
<td>{{currentRow[0]}}</td>
<div rmx-schedule-row time="currentRow" time-from="{{currentRow[0]}}" time-to="{{currentRow[1]}}" date="{{dateStr}}"/>
</tr>
和指令:
rmx.directive('rmxScheduleRow', function(scheduleService) {
return {
scope: {
time: "=",
date: "@",
timeFrom: "@",
timeTo: "@"
},
controller: [
"$scope", "$rootScope", "$element", "$attrs", "$http",
function($scope, $rootScope, $elm, $attrs, $http) {
$attrs.$observe('timeFrom', function(val) {
console.log("change has been detected");
console.log($scope);
console.log($attrs);
console.log(val);
});
}
]
};
});
在视图中, currentRow[0] 被正确评估并打印出预期的结果。
但在指令中,currentRow[0] 和 [1] 被内插为空字符串 (""),而对象time
被内插为 undefined。我会因为试图发现错字或其他东西而发疯:(
我尝试$scope.$watch
了相同的结果。