如何重新加载具有不同参数的div?

我有一些标签。 在选择每个选项卡时,应使用与每个选项卡对应的一些特定参数值初始化特定div并重新加载。 怎么做到呢?

以下是标签:

District:

在你的情况下,你应该使用更适合使用的ng-route ,只需要根据url更改导航栏中的URL,你需要使用$routeProvider配置中指定的控制器加载模板

  

Template.html

  
District:

App.js

  var app= angular.module('app', ['ngRoute']); app.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/tab/:id', { templateUrl: 'template.html', controller: 'templateController' }). otherwise({ redirectTo: '/tab/1' }); }]); 

调节器

 app.controller('templateController', function($scope, $routeParams){ //every time the tab change will cause reload this controller using route provider //here you can have tab number in $routeParams.id $scope.tabId = $routeParams.id; //now you have a tab number you can do use this tab id in your further code execution //..other code here.. }); 

我希望更改$ scope.districts,以下选择显示相应的选项

你可以通过很多方式做到这一点。

遵循伪代码作为示例:

 $scope.districts = [] $scope.setTab = function(tab) { var res = []; if (tab == 1) { res = $scope.districts.filter(function(item) { return item == something; }); }else{ res = $scope.districts.filter(function(item) { return item != something; }); }; $scope.districts = res; }