我有一个这样配置的路由器:
.state('home.view-profile', {
url: '/view-profile/:profileUrl',
template: '<view-profile input="$resolve.profileData"></view-profile>',
title: 'View Profile',
resolve: {profileData: function(artistService, $stateParams){
return artistService.getArtist($stateParams.profileUrl).then((data) => {
const timer = new Date();
console.log(timer.getSeconds() + ':' + timer.getMilliseconds());
console.log(data.data.artist);
return data.data.artist;
});
}
}
})
和组件
module.component('view-profile', {
templateUrl: 'view-profile/view-profile.component.html',
bindings: {
input: '='
},
controller: ['$state', '$scope', '$stateParams', function ($state, $scope, $stateParams) {
const model = this;
console.log('***************');
console.log(model.input);
}]
});
data.data.artist
我可以在解析过程中看到它是有效的并且可以从日志中访问,但是在组件内部input
总是undefined
J 只是不明白为什么会发生这种情况?