我的导航栏出现问题。我使用了AngularJs的ngRoute,我无法理解为什么所有链接在点击时都会出错。
这是我的代码:
app.ts文件:
module AnimalPlanet {
export var app: angular.IModule;
app= angular.module("mainAnimalPlanet",["ngRoute"]);
app.config(['$routeProvider', ($routeProvider:ng.route.IRouteProvider, $locationProvider:angular.ILocationProvider) => {
$routeProvider.when('/', {
templateUrl: 'templates/main.html',
controller:"a"
})
.when('/pets', {
templateUrl: 'templates/pets.html',
controller:"MenuItemCtrl"
})
.when('/ldAdoption', {
templateUrl: 'templates/ldAdoption.html',
controller:"c"
})
.when('/111111', {
templateUrl: 'templates/contact.html',
controller:"d"
})
.when('/impressum', {
templateUrl: 'templates/impressum.html',
controller:"e"
})
.otherwise({
redirectTo: '/'
});
}]);
}
menuItem.ts文件: "使用严格的&#34 ;;
模块AnimalPlanet {
export class MenuItemCtrl {
names: any[];
constructor(names) {
this.names = [{
name: "Main",
slug: "main",
active: true,
link: "/"
}, {
name: "Pets",
slug: "pets",
active: false,
link: "/pets"
}, {
name: "LDAdoption",
slug: "ldAdoption",
active: false,
link: "/ldAdoption"
}, {
name: "Contact",
slug: "contact",
active: false,
link: "/contact"
}, {
name: "Impressum",
slug: "impressum",
active: false,
link: "/impressum"
}];
}
}
angular.module('mainAnimalPlanet',['ngRoute']).controller("MenuItemCtrl", ["$scope", MenuItemCtrl]);
}
请帮帮我!!!谢谢!