I'm having trouble figuring out how to use an object in an angular template in a custom directive. Here's a plunker to explain what kind of trouble I'm having.
我无法弄清楚如何在自定义指令中使用角度模板中的对象。这是一个解释我遇到了什么样的麻烦的傻瓜。
After some fiddling around i came to the conclusion that i need to use scope: {address: '='}
in order to pass in an object into the directive's template instead of scope: {street: '@'}
which is what i used for the street value. However it is throwing a parsing error, and not displaying the address's country correctly. Can someone help explain what I'm doing wrong here? I've looked at dozens of examples but can't quite figure out how to fix it.
经过一些摆弄我得出的结论是我需要使用范围:{address:'='}以便将对象传入指令的模板而不是范围:{street:'@'}这是我用的对于街道价值。但是它会抛出一个解析错误,而不是正确显示地址的国家/地区。有人可以帮助解释我在这里做错了吗?我看过几十个例子,但还不清楚如何修复它。
这是我想要实现的一个简单的工作示例但由于某种原因我不能复制这个
1 个解决方案
#1
1
Remove the double braces around your object.
删除对象周围的双括号。
<address-b address="user.address"></address-b>
#1
1
Remove the double braces around your object.
删除对象周围的双括号。
<address-b address="user.address"></address-b>