पर क्लिक करने के बाद कोणीय बूटस्ट्रैप टैब यूआरएल बदलते हैं I प्रोजेक्ट में Bootstrap's Tabs का उपयोग करते हैं। बाद एक टैब क्लिक किया जाता है, मैं यूआरएल की तरह इस तरह, बदलने के लिए होगा:टैबर
/home/first
/home/second
लेकिन मैं इसे ठीक करने के लिए पता नहीं है। यहाँ मेरी $routeProvider
कोड है:
$routeProvider
.when('/:appId/home', {
templateUrl: 'app/home/home.html',
controller: 'homeController'
})
.when('/:appId/home/first', {
templateUrl: 'app/home/first/first.html',
controller: 'firstController'
})
युपीडी निर्देशक कोड:
'use strict';
angular.module('bootstrap.tabset', [])
.directive('tabset', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
controller: function($scope) {
$scope.templateUrl = '';
var tabs = $scope.tabs = [];
var controller = this;
this.selectTab = function (tab) {
angular.forEach(tabs, function (tab) {
tab.selected = false;
});
tab.selected = true;
};
this.setTabTemplate = function (templateUrl) {
$scope.templateUrl = templateUrl;
};
this.addTab = function (tab) {
if (tabs.length == 0) {
controller.selectTab(tab);
}
tabs.push(tab);
};
},
template:
'<div class="row-fluid">' +
'<div class="row-fluid">' +
'<div class="nav nav-tabs" ng-transclude></div>' +
'</div>' +
'<div class="row-fluid">' +
'<ng-include src="templateUrl">' +
'</ng-include></div>' +
'</div>'
};
})
.directive('tab', function() {
return {
restrict: 'E',
replace: true,
require: '^tabset',
scope: {
title: '@',
templateUrl: '@'
},
link: function(scope, element, attrs, tabsetController) {
tabsetController.addTab(scope);
scope.select = function() {
tabsetController.selectTab(scope);
}
scope.$watch('selected', function() {
if (scope.selected) {
tabsetController.setTabTemplate(scope.templateUrl);
}
});
},
template:
'<li ng-class="{active: selected}">' +
'<a href="" ng-click="select()">{{ title }}</a>' +
'</li>'
};
});
होम पेज HTML:
<tabset>
<tab title="Tab 1" template-url="/app/home/first/first.html"></tab>
<tab title="Tab 1" template-url="/app/home/home.html"></tab>
</tabset>
app.js
angular.module('frontend', ['ngRoute', 'ui.bootstrap', 'localytics.directives'])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/main/main.html',
controller: 'MainCtrl'
})
.when('/:appId/home', {
templateUrl: 'app/home/home.html',
controller: 'homeController'
})
.when('/:appId/home/first', {
templateUrl: 'app/home/first/first.html',
controller: 'firstController'
})
.otherwise({
redirectTo: '/'
});
})
यह आपकी समस्या का समाधान में मदद करने के लिए यदि आप कुछ और कोड अधिमानतः एक काम डेमो पोस्ट कर सकता, आसान होगा .. – atefth
@atefth मैंने अपना प्रश्न अपडेट किया –
क्या आप अपना ऐप.जेएस और कंट्रोलर कोड भी पोस्ट कर सकते हैं? – atefth