【发布时间】:2017-04-12 06:43:13
【问题描述】:
在 html 中,我将此对象传递给指令
<lcd-code ldcCode="{{ detail.program.ldcCode }}"></lcd-code>
detail.program.ldcCode = "PSIH" ...
然而在指令中它是未定义的
var lcdCode = function (customerService, $sce) {
return {
replace: true,
restrict: "E",
scope: {
ldcCode: "=" // two way
},
link: function (scope, element, attrs) {
console.log('scope.ldcCode',scope.ldcCode); // says undefined
}
};
}
以前我使用“@”,然后 attrs.ldcCode 似乎可以工作......我猜我正在处理的数据的最终结果并发回我想我想要 2 路数据绑定。
【问题讨论】:
标签: javascript angularjs angularjs-scope angular-directive