【发布时间】:2017-02-17 00:41:57
【问题描述】:
我对开发真的很陌生。我正在学习 AngularJS。
我遇到了 yo angular 的问题。它正在生成应用程序,grunt serve 在本地运行。但是当我单击关于按钮时,它不会转到关于页面
这是一些代码(这些是由角度生成器生成的)。
index.html
div class="collapse navbar-collapse" id="js-navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#/">Home</a></li>
<li><a ng-href="#/about">About</a></li>
<li><a ng-href="#/">Contact</a></li>
</ul>
</div>
</div>
</div>
</div>
app.js(来自脚本文件夹)
'use strict';
angular
.module('coolAppApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'main'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl',
controllerAs: 'about'
})
.otherwise({
redirectTo: '/'
});
});
【问题讨论】:
-
你知道是哪部分代码导致了问题吗?
-
我假设 .when('/about', { templateUrl: 'views/about.html', controller: 'AboutCtrl', controllerAs: 'about' })
-
找到解决方案@ABusyProgrammer
标签: angularjs yeoman-generator yeoman-generator-angular