简体   繁体   English

AngularJS ng-view,ng-click和routerProvider不能一起工作

[英]AngularJS ng-view, ng-click and routerProvider not working together

I've been scratching my head for some time over this puzzle. 在这个难题上,我一直在摸不着头脑。 I've been trying to load an external file into an ng-view (no problems here). 我一直在尝试将外部文件加载到ng-view中(这里没有问题)。 And in that partial file I have text that get swapped for an input field when you click "Edit title", but this only works when all code is included in the same file. 在该部分文件中,当您单击“编辑标题”时,我的文本将被替换为输入字段,但这仅在所有代码包含在同一文件中时才有效。

If you take a look at this Plunker http://plnkr.co/edit/cgUGOKVzWKNWugqrFCbJ you'll see what I mean. 如果你看看这个Plunker http://plnkr.co/edit/cgUGOKVzWKNWugqrFCbJ,你会明白我的意思。

I would appreciate if you could point me in a direction that could solve this issue for me. 如果你能指出我可以解决这个问题的方向,我将不胜感激。

Thanks! 谢谢!

The "#" in the hrefs are probably making angular render the html and the controller again. href中的“#”可能会再次对html和控制器进行角度渲染。

Change them as below and it should work: 如下更改它们,它应该工作:

<a href="javascript:void(0)" ng-click="enableEditor()">Edit title</a>

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

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