【发布时间】:2018-02-02 16:16:29
【问题描述】:
我知道这篇帖子Angular 1.5 component attribute presence 应该回答我的问题,但我做了所有事情都像他们一样,我仍然无法恢复我的数据!如果你知道为什么.. :)
组件:
component('ficheOperation', {
templateUrl : 'operations/creerOperation.template.html',
bindings : {
idOp : '<'
},
controller : ['$scope', '$routeParams', '$location',
function ficheOperationController($scope, $routeParams, $location){
var self = this;
console.log(self.idOp);
}]
})
HTML:
<fiche-operation idOp="33"></fiche-operation>
模板已正确加载,但在我的控制台中,我得到的只是一个可怕的“未定义”。
谢谢
【问题讨论】:
-
你试过console.log(self)吗?可以显示一些有用的东西..
-
它显示了包含 idOp 但未定义的对象,真的很奇怪,如果我发现有什么问题我会更新这个
-
我认为在这里命名函数没有意义。
ficheOperationController可能会导致您的问题。应该只是function($scope, $routeParams, $location) -
我在删除“ficheOperationController”后尝试过,它的工作原理相同,很好,但没有检索属性,但谢谢 :)
标签: angularjs angularjs-components