在angularJS中的控制器内部嵌套App

时间:2015-10-26 06:55:00

标签: javascript angularjs

如何在AnglularJS中实现该结构?

<body ng-app="mainBodyAppWrapper">
        <div ng-controller = "mainBodyController">
            <div ng-app="myApp">
                <div ng-controller="controller3">
                    First Name : <input ng-model="myApp_fName3" type="text"/>
                    Last Name : <input ng-model="myApp_lName3" type="text"/>
                    Hello {{myApp_fName3}} {{myApp_lName3}} !!!
                </div>
                <hr/>
            </div>
        </div>
    </body>

在这种情况下,我有一个错误https://docs.angularjs.org/error/ng/areq?p0=controller3&p1=not%20a%20function,%20got%20undefined

有谁知道这种错误解决方案?请帮帮我

1 个答案:

答案 0 :(得分:1)

您无法在页面中使用多个ng-app。如果您确实需要使用多个模块,请考虑引导第二个模块。有关详细信息,请阅读How to define two angular apps / modules in one page