【发布时间】:2014-12-26 23:03:33
【问题描述】:
指令中 score_stats 的值始终未定义,并且在父作用域中,stats 变量具有正确的值。我做错了什么?
我在模板中有这段代码(并且 fixtures_stats 是一个数组):
div(ng-repeat="stats in fixture_stats")
scenario-analysis(score_stats="stats")
指令中的这段代码:
{
templateUrl: '/' + appVersion + '/directives/scenario-analysis.html',
scope:{
score_stats:'=score_stats'
},
controller: function($scope, $element, $attrs) {
console.log('directive $scope.score_stats: ' + $scope.score_stats +
', $scope.$parent.stats: ' + $scope.$parent.stats);
},
};
指令模板中的这段代码:
h3 Scenarios for {{ score_stats.score1 }}-{{ score_stats.score2 }} score combo
在控制台中我得到:
directive $scope.score_stats: undefined, $scope.$parent.stats: [object Object]
directive $scope.score_stats: undefined, $scope.$parent.stats: [object Object]
【问题讨论】:
标签: angularjs angularjs-directive angularjs-scope