var m1=angular.module('myApp', ['ui.router']);
m1.component('index',{
template:'<h1>{{name}}</h1>',
});
m1.component('user',{
template:'<h1>{{name}}</h1>',
});
m1.config(function($stateProvider) {
var indexState = {
name: 'index',
url: '/index',
component:'index'
}
var userState = {
name: 'user',
url: '/user',
component:'user'
}
$stateProvider.state(indexState);
$stateProvider.state(userState);
});
Excuse me, the template content in the two states here is not displayed in the browser. May I ask why?
I tried it and it seems that it is a version problem. The configuration of ui-router may not have the component attribute.
Change component:'user' to template:'<user></user>' Just use component as a directive