Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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中的多个页面_Angularjs - Fatal编程技术网

如何在单个节中显示和隐藏angularjs中的多个页面

如何在单个节中显示和隐藏angularjs中的多个页面,angularjs,Angularjs,我有3页1.html、2.html和3.html,有3个不同的按钮button1、button2和button3。在button1上单击我想显示1.html,在button2上单击2.html,依此类推。我们如何在angularJs中实现这一点?您可以使用ng include来实现这一点,将html移动到脚本标记,并在单击按钮时更改ng include值 以下是示例为什么不使用ui路由器? 您可以使用angular routerng route(第三方状态提供程序,如ui router),手动使

我有3页1.html、2.html和3.html,有3个不同的按钮button1、button2和button3。在button1上单击我想显示1.html,在button2上单击2.html,依此类推。我们如何在angularJs中实现这一点?

您可以使用ng include来实现这一点,将html移动到脚本标记,并在单击按钮时更改ng include值
以下是示例

为什么不使用
ui路由器


您可以使用angular router
ng route
(第三方状态提供程序,如
ui router
),手动使用
ng include
,或其他一些方法来实现这一点。这太宽泛了,无法向您提供所有可能的解决问题的方法。您能帮我举个例子吗?在链接的底部有一个例子,请检查。我已将html代码移动到脚本“vm.templates=[{name:'template1.html',url:'template1.html'},{name:'template2.html',url:'template2.html'}];'并在按钮单击事件中调用名称。“”但它仍然不起作用。和“ng-click=“changemplate”(“template2.html”)$scope.changemplate=function(name){$scope.template.url=name}