我想将控制器注入其他模块。我有两个文件如何将控制器注入其他模块
- 的index.html
- app.js
的index.html的代码如下
<body ng-app="mainApp" ng-controller="mainCtrl">
<h1>{{lab}}</h1>
<h1 ng-controller="secCtrl">{{lab2}}</h1>
</body>
和app.js是如下
var myapi = angular.module('mainApp', []);
myapi.controller('mainCtrl', function($scope){
$scope.lab='Hello'
return{
controller:'secCtrl'
}
});
myapi.controller('secCtrl', function($scope) {
$scope.lab2='Hello you are secCtrl'
});
如果问题需要澄清,只是不,直到它足够清楚的回答。不好的问题会导致不好的答案。 – estus