DefinitelyTyped/angular-ui/angular-ui-router-tests.ts
2013-12-22 14:55:09 +04:00

61 lines
1.5 KiB
TypeScript

/// <reference path="angular-ui-router.d.ts" />
var myApp = angular.module('testModule');
interface MyAppScope extends ng.IScope {
items: string[];
things: string[];
}
myApp.config((
$stateProvider: ng.ui.IStateProvider,
$urlRouterProvider: ng.ui.IUrlRouterProvider) => {
//
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/state1");
//
// Now set up the states
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
})
.state('state1.list', {
url: "/list",
templateUrl: "partials/state1.list.html",
controller: function ($scope: MyAppScope) {
$scope.items = ["A", "List", "Of", "Items"];
}
})
.state('state2', {
url: "/state2",
templateUrl: "partials/state2.html"
})
.state('state2.list', {
url: "/list",
templateUrl: "partials/state2.list.html",
controller: function ($scope: MyAppScope) {
$scope.things = ["A", "Set", "Of", "Things"];
}
}).state('index', {
url: "",
views: {
"viewA": { template: "index.viewA" },
"viewB": { template: "index.viewB" }
}
})
.state('route1', {
url: "/route1",
views: {
"viewA": { template: "route1.viewA" },
"viewB": { template: "route1.viewB" }
}
})
.state('route2', {
url: "/route2",
views: {
"viewA": { template: "route2.viewA" },
"viewB": { template: "route2.viewB" }
}
});
});