欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

angularJs常用事件

程序员文章站 2022-04-10 14:09:15
...

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"
相关标签: angular