首页 > templateUrl和templateProvider的注入问题

templateUrl和templateProvider的注入问题

最近在学习angular的使用,用到了ui-router路由框架,看Templates时,看到了这两句话,不太理解,请指教,谢谢!
https://github.com/angular-ui...

// 项目中app.js推测应该像下面这样,如有错误的地方还请指出来
angular.module('myApp', [ui.router])
    .config(function($stateProvider /* 这个地方依赖注入? */){
        $stateProvider
            .state('contacts', {
              templateUrl: function ($stateParams){
                return '/partials/contacts.' + $stateParams.filterBy + '.html';
              }
            })
            .state('other', {
              templateProvider: function ($timeout, $stateParams) {
                return $timeout(function () {
                  return '<h1>' + $stateParams.contactId + '</h1>'
                }, 100);
              }
            })
    })
【热门文章】
【热门文章】