角度指令 将属性解释为字符串
Angular Directive Interpreting attribute as string
我的指令如下
angular
.module('app.directives')
.directive('myTable',function(){
function linkFn(
scope,
element,
attrs
) {
console.log(attrs.attributes);
}
return {
link: linkFn,
template: 'some.html',
scope: {
attributes: '=',
},
replace : true
}
});
我使用该指令作为
<my-table attributes="management.table.attributes"></my-table>
但是,link 函数中的 attrs.attribute
值解析为字符串management.table.attributes
,而不是数组。
我将不胜感激任何形式的帮助或指导。
谢谢!
attrs.attribute
总是一个字符串,因为根据定义,属性是字符串。您需要相应的scope.attributes
该对象将被评估的对象引用:
console.log(scope.attributes);
相关文章:
- Javascript 如何强制 string.replace 不将我的字符串解释为正则表达式
- 注入的HTML仅在Dom中解释为字符串
- 如何将JS字符串解释为文件或在Bundlebars中使用字符串
- 传递的URL字符串未解释为字符串
- 让日期字符串在浏览器中得到相同的解释
- 用“i”替换字符串中的元音..你能解释一下这个表达吗?someText.replace(/[aAeEoOuU]/ig,“
- 角度指令 将属性解释为字符串
- 数组中的字符串“”被解释,是否有解决方法
- 如何将文件内容解释为模板字符串
- 将 grunt 命令行选项解释为字符串
- 谁能解释这种关于字符串连接的奇怪 JS 行为
- 在Javascript字符串文本中解释HTML标记
- 将javascript连接字符串解释为变量
- Salesforce中的对象在Google Apps Script/Javascript中被解释为字符串
- 生成一个与Javascript字符串匹配的Regex对象.解释方法
- AJAX响应被解释为字符串
- 需要解释这个Javascript字符串资本主义原型
- DataBinder.Eval返回的值被解释为变量而不是字符串
- 字符串在附加时被解释为HTML标记
- 需要解释字符串"<%= text %>"