Angularjs 如何将角度控制器包含到ui路由器模型中
我是个新手。我想将我的控制器lib/AppController.js包含到我的ui路由器模块中,以显示在索引页上。好心帮忙 这是我的 index.htmlAngularjs 如何将角度控制器包含到ui路由器模型中,angularjs,angular-ui-router,angularjs-routing,Angularjs,Angular Ui Router,Angularjs Routing,我是个新手。我想将我的控制器lib/AppController.js包含到我的ui路由器模块中,以显示在索引页上。好心帮忙 这是我的 index.html <body> <div ui-view="home"></div> </body> Appcontroller.js (功能(窗口){ 在appmodule.js中,只需添加它 var weatherapp = angular.module('weatherapp', ["ui.ro
<body>
<div ui-view="home"></div>
</body>
Appcontroller.js
(功能(窗口){
在appmodule.js中,只需添加它
var weatherapp = angular.module('weatherapp', ["ui.router","weatherAppCtr"])
^
Here
有两种方法可以做到这一点,您可以使用两个模块并将其中一个包含在另一个模块中,或者对配置和控制器使用相同的模块,如Appcontroller.js中所示: 删除此行:
var weatherAppCtr = angular.module('weatherAppCtr',[]);
并修改此模块,使其与控制器和配置具有相同的模块:
weatherapp.controller('weatherCtrl',["$scope", "$http", function($scope, $http){
^Here
var weatherAppCtr = angular.module('weatherAppCtr',[]);
weatherapp.controller('weatherCtrl',["$scope", "$http", function($scope, $http){
^Here