Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何在ng include html页面中触发parentcontroller事件?_Angularjs_Angularjs Scope_Angularjs Ng Include - Fatal编程技术网

Angularjs 如何在ng include html页面中触发parentcontroller事件?

Angularjs 如何在ng include html页面中触发parentcontroller事件?,angularjs,angularjs-scope,angularjs-ng-include,Angularjs,Angularjs Scope,Angularjs Ng Include,使用ng include,我在index.html中包含了一个模板,在其中我包含了另一个html页面alert.html。 我的问题是我可以访问父控制器的范围变量,但是我不能绑定父控制器的事件 index.html addresform.html Name in AddressForm <ng-include src="'alert.html'"></ng-include><br> alert.html <input type="button"

使用ng include,我在index.html中包含了一个模板,在其中我包含了另一个html页面alert.html。 我的问题是我可以访问父控制器的范围变量,但是我不能绑定父控制器的事件

index.html

addresform.html

 Name in AddressForm 
  <ng-include src="'alert.html'"></ng-include><br>
alert.html

<input type="button" value="{{name}}" ng-click="clickMe({{name}})">
{{testVal}}

按钮的代码应该是

<input type="button" value="{{name}}" ng-click="clickMe(name)">
您不需要用{{}插入name var,因为在ng click=clickMename中,它已经是一个表达式了


演示:感谢您的快速回答。您的解决方案在这方面运行良好。但在我的实际应用程序中..我使用ng include在index.html中包含了outpt.html,在outpt.html中,我在一个div中又包含了一个alert.html,其中,默认情况下,this alert.html是隐藏的。此外,当我单击outpt.html上的按钮时,我会在alert对话框中覆盖自定义UI的window.alert方法。我会将整个alert.html父div html连同jquery发送到我的自定义alertmsgex:html内容,title方法。在这种情况下,我无法从警报触发事件。请告诉我什么可能是prblm。我不确定我是否遵循。您能否创建单独的问题并详细描述您的问题?请检查此项。
<input type="button" value="{{name}}" ng-click="clickMe({{name}})">
{{testVal}}
<input type="button" value="{{name}}" ng-click="clickMe(name)">