问题描述
在不使用打字稿,我将这样我的UI路由器状态信息之前:
Before when not using Typescript I was adding my ui-router state information like this:
app.config([
'$httpProvider',
'$locationProvider',
'$sceProvider',
'$stateProvider',
appConfig
]);
function appConfig(
$httpProvider,
$locationProvider,
$sceProvider,
$stateProvider
) {
$locationProvider.html5Mode(true);
$sceProvider.enabled(false);
var admin = {
name: 'admin',
url: '/admin',
views: {
...
}
};
现在我用的打字稿我想我应该code到这一类。但是,我怎么能将该类添加到我的应用程序?我已经有这个code其中我添加了一个控制器:
Now I am using Typescript I assume I should code this into a class. But how can I add the class to my app? I already have this code where I added a controller:
var app = angular.module('app',
[
])
.controller('appController', AppController);
我试着状态信息添加为的.config但看来这只能接受一个函数作为参数。
I tried to add the state information as a .config but it appears this only accepts a function as the argument.
有人能告诉我怎么能为UI的路由器加入我的状态信息,以我的应用程序?
Can someone tell me how I can add my state information for ui-router to my app?
推荐答案
您不会从这里使用类获得优势,因为你不需要使用这个
或配置
功能属性添加到它。只需使用一个函数像它的JavaScript(打字稿不会抱怨)。
You wouldn't gain an advantage from using a class here because you don't need to use this
or add properties to it in the config
function. Just use a function like its JavaScript (TypeScript won't complain).
这篇关于如何添加UI路由器stateProvider配置,以我的打字稿的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!