angular.js - component in Angular1 ui-router has no effect?
PHP中文网
PHP中文网 2017-05-15 17:11:29
0
1
557
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?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
阿神

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template