angular 常用配置

var furShare = angular.module('furShare', ['ngRoute']);
furShare.config(function($httpProvider) {
    var contentType = 'application/x-www-form-urlencoded;charset=utf-8';
    $httpProvider.defaults.headers.post['Content-Type'] = contentType;
    $httpProvider.defaults.transformRequest = function(data) {
        if (data) {
            return $.param(data);
        } else {
            return;
        }
    };
});
furShare.config(['$routeProvider',
    function($routeProvider) {
        $routeProvider
            .when('/main', {
                templateUrl: 'main.html'
            }).otherwise({
                redirectTo: '/activity'
            });
    }
]);


你可能感兴趣的:(angular 常用配置)