模块路线:
var switchModule = angular.module('switchModule', []);
switchModule.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/build-content', {templateUrl: 'build-content.html', controller: BuildInfoController});
}]);
Run Code Online (Sandbox Code Playgroud)
控制器:
function BuildInfoController($http, $scope){
alert("hello");
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<html ng-app="switchModule">
...
<body>
<ul>
<li><a href="#build-content"/></a></li>
</ul>
<div class="ng-view"></div>
</body>
...
Run Code Online (Sandbox Code Playgroud)
每次当我点击超链接''时,'BuildInfoController'将被调用两次.我错过了什么吗?