简体   繁体   English

将隔离的范围对象传递到角度自定义指令模板中?

[英]Pass in isolated scope object into angular custom directive template?

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. 经过一番摆弄之后,我得出结论,我需要使用scope: {address: '='}才能将对象传递到指令的模板而不是scope: {street: '@'}街道价值。 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. 我看了几十个示例,但还不太清楚如何解决它。

Here's a simple working example of what i'm trying to achieve but for some reason I can't replicate this 这是我要实现的目标的简单工作示例,但由于某些原因,我无法复制此示例

删除对象周围的双括号。

<address-b address="user.address"></address-b>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM