TypechoJoeTheme

IT技术分享

统计

AngularJS-Router 模板

2016-08-05
/
0 评论
/
795 阅读
/
正在检测是否收录...
08/05

1、JS配置

'use strict';
var app = angular.module('app', [
    'ngAnimate',
    'ngCookies',
    'ngStorage',
    'app.controllers',
    'msgbox'
])

 app.config(
    ['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$compileProvider', '$filterProvider', '$provide',
        function ($stateProvider, $urlRouterProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) {

            app.controller = $controllerProvider.register;
            app.directive = $compileProvider.directive;
            app.filter = $filterProvider.register;
            app.factory = $provide.factory;
            app.service = $provide.service;
            app.constant = $provide.constant;
            app.value = $provide.value;

            $urlRouterProvider
                .otherwise('/app/');
            $stateProvider
                .state('app', {
                    abstract: true,
                    url: '/app',
                    templateUrl: 'tpl/app.html',
                    resolve: {
                        deps: ['uiLoad',
                            function (uiLoad) {
                                return uiLoad.load([
                                    'css/bootstrap.css',
                                    'js/libs/moment.min.js'
                                ]);
                            }]
                    }
                })
                .state('home', {
                    url: '/home',
                    template: '<div ui-view class="fade-in-right-big smooth">Hello word</div>'
                })
        }
    ]
)

二、HTML调用

<a ui-sref="home">Home</a>
朗读
赞 · 0
版权属于:

IT技术分享

本文链接:

https://idunso.com/archives/2118/(转载时请注明本文出处及文章链接)