在AngularJS一个transcluded指令中使用`NG-model` [英] Using `ng-model` within a transcluded directive in AngularJS

查看:88
本文介绍了在AngularJS一个transcluded指令中使用`NG-model`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正我有可以使用使用 NG-模型指令的transclusion内?

Is there anyway I can use use ng-model within a transclusion of a directive?

我已经在这里张贴的code // plunker .no.de /编辑/ XWAUp7?活= preVIEW

I have posted the code here: http://plunker.no.de/edit/XWAUp7?live=preview

我期待着有人给我意见。

I look forward to somebody to give me advice.

推荐答案

这是因为,您将围绕一个基本类型。如果您使用的是引用类型,像一个对象或数组,它的工作好了很多。我已经改变了这里的普拉克这个演示

It's because you're passing around a primitive type. If you use a reference type, like an object or an array, it will work a lot better. I've changed your plunk here this demo

请注意,我只好一个对象传递到fOuter,使其工作。同样,在fInner,如果原始的是对象的孩子,这两种方式都可以。

Notice I had to pass an object into fOuter to make it work. Likewise, on fInner, if the primitive is the child of an object, it works both ways.

编辑:看起来像Guillaume86在评论中回答。同样的答案,真的。

Looks like Guillaume86 answered in the comments. Same answer, really.

这篇关于在AngularJS一个transcluded指令中使用`NG-model`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆