Angularjs ngRoute不适用于类型脚本
我正在尝试将ngRoute与typescript一起使用。当我运行页面时,它不会显示模板。它也没有给出任何错误。我检查了模板的url,它在那里,因为它应该。你知道为什么我在浏览器上找不到任何页面吗Angularjs ngRoute不适用于类型脚本,angularjs,typescript,ngroute,Angularjs,Typescript,Ngroute,我正在尝试将ngRoute与typescript一起使用。当我运行页面时,它不会显示模板。它也没有给出任何错误。我检查了模板的url,它在那里,因为它应该。你知道为什么我在浏览器上找不到任何页面吗 ///<reference path="../../typings/tsd.d.ts"/> ///<reference path="tlob.d.ts"/> module tlob { export class Route {
///<reference path="../../typings/tsd.d.ts"/>
///<reference path="tlob.d.ts"/>
module tlob {
export class Route {
constructor(module:angular.IModule) {
if (console) {
console.log('module.route initializing...');
}
module.requires.push('mgcrea.ngStrap'); // register AngularStrap
angular.module('tlob.route', ['ngRoute']) // create new Angular Module
.config(['$routeProvider', function ($routeProvider: angular.route.IRouteProvider) {
$routeProvider.otherwise('/');
$routeProvider
.when('/', {
templateUrl: 'ts/page1/page1.html'
})
}]);
module.requires.push('tlob.route'); // add Angular Module to dependencies
module.requires.push('ngRoute');
if (console) {
console.log('module initialized');
}
}
}
}
您是否检查了浏览器开发工具以查看http请求是否指向正确的文件?是的,因此实际上没有针对HTMLCOLD的http请求。您可以共享该类的初始化方式吗?确保其处于updateuhm下。。类的构造函数中的代码只有在调用新类名时才会运行。。我有种感觉,像那样的东西不见了您可以尝试调试代码以确保:
module tlob {
export class tlob {
private module:angular.IModule = null;
constructor() {
if (console) {
console.log('module tlob initializing...');
}
this.module = angular.module('tlob', ['ngSanitize']);
this.module.controller('TestController', ['$scope', function($scope) {
console.log('TestController initialized');
}]);
new Configuration(this.module); // setup configuration e.g. Logging
new Route(this.module); // setup routes
if (console) {
console.log('module tlob initialized');
}
}
static getModule():angular.IModule {
return angular.module('tlob');
}
}
}