angularJs常用事件

ui-router禁用缓存

 //配置路由
app.config(function ($stateProvider, $urlRouterProvider, $httpProvider) {
    //禁止缓存
    if (!$httpProvider.defaults.headers.get) {
        $httpProvider.defaults.headers.get = {};
    }
    // Enables Request.IsAjaxRequest() in ASP.NET MVC
    $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';

    // Disable IE ajax request caching
    $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
    $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
    $httpProvider.defaults.headers.get['If-Modified-Since'] = '0';
   
    $urlRouterProvider.otherwise("/order_1"); //默认首页
    $stateProvider.state("order_1", { url: "/order_1", templateUrl: "/OrderInfo?orderState=0", controller: "OrderAllController" })
});

//清除缓存
app.run(function ($rootScope, $templateCache) {
    $rootScope.$on('$viewContentLoaded', function () {        
        $templateCache.removeAll();
    });
});

ui-router传参

ui-sref="workbench({type:1})"
//接收参数
app.controller('WorkbenchCtrl', function ($stateParams, $scope) {
	console.log($stateParams.type);
});
//templateUrl传参
templateUrl: function($stateParams){return 'project/'+$stateParams.id;},

ng-repeat含有重复项在后边加 track by $index

ng-repeat="data in postNum track by $index"

猜你喜欢

转载自blog.csdn.net/weixin_39703839/article/details/84875201