angular 爬坑指南

他的 组件 和 ctrl方法 是这样写的 在路由里面 是 template 属性 引入组件 版本不一样 可能就悲剧了

 .config(function($stateProvider, $urlRouterProvider) {
         $urlRouterProvider.otherwise('/');
         const allState = {
             name: 'hotpub',
             url: '/',
             template:'<hotpub></hotpub>',


         };
         const activeState = {
             name: 'senspub',
             url: '/senspub',
             template:'<senspub></senspub>'
         };
         $stateProvider.state(allState);
         $stateProvider.state(activeState);
     })
//  热门公众号 /敏感公众号(组件)
     .component('hotpub', {
            templateUrl: 'hotpub.html',
            controller: function () {
                this.hotviewModle = [
                    {publicNum: '阿斯顿发',
                        wxNum: '比亚迪汽车金融有限公司',
                        relaNum: '288',
                        id: 1
                    },
                    {publicNum: '阿斯顿发',
                        wxNum: '比亚迪汽车金融有限公司',
                        relaNum: '288',
                        id: 2
                    }
                ]
            }
        })
     .component('senspub', {
            templateUrl: 'senspub.html',
            controller: function () {
                this.sensviewModle = [
                    {publicNum: '阿斯顿发',
                        wxNum: '比亚迪汽车金融有限公司',
                        relaNum: '288',
                        id: 1
                    },
                    {publicNum: '阿斯顿发',
                        wxNum: '比亚迪汽车金融有限公司',
                        relaNum: '288',
                        id: 2
                    }
                ]
            }
        }

posted on 2017-05-02 15:36  fxxk院子  阅读(51)  评论(0)    收藏  举报

导航