当我使用组件时,如何使用UI路由器解析变量。
这是路线:
$stateProvider
.state('route', {
url: '/route',
template: '<my-component user="user"></my-component>',
resolve: {
user: (Auth) => {
return Auth.getCurrentUser().$promise;
}
}
})
这是组件:
(function () {
class BookingListComponent {
constructor(user) {
//I want to use the user here but getting the unknown provider error
}
}
angular.module('app')
.component('myComponent', {
templateUrl: 'my-url.html',
controller: MyComponent,
bindings: {
user: '<'
}
});
})();
使用Angular 1.5和yeoman angular-fullstack