Show Or Hide The Element Based On The User Input
Solution 1:
You should use RouteProvider and routeParams.
For example
$routeProvider.when('/yourView/:param1/:param2', {
templateUrl:'yourViewHTMLFile.html',
controller:'yourController'
});
Now get the values of params
given in the URL
by injectingn$routeParams
in your controller as
.controller('yourController', ['$scope','$routeParams', function($scope,
$routeParams) {
$scope.param1 = $routeParams.param1; // just as an example to model this in viewvar param2 = $routeParams.param2; //change here from param1 to
param2
...
}]);
Next is simple. Simply show/hide tabs based on the values.
For example
<div id='tab1'>Tab1</div>
<div id='tab2'>Tab2</div>
<div id='tab3' ng-show='{{param1 =='testValue'}}'>Tab3</div>
Solution 2:
You need to use location
provider in your JavaScript
https://docs.angularjs.org/api/ng/service/$location
const url = location.url();
and update your condition in your HTML ng-if="tabName === 'Tab3' || url === 'http://myURL.com/showAll'"
You are also have two ids of tab2
in your HTML, which you should fix and you are missing a col-sm-12
div
container in tab1
Solution 3:
For this you will need ui-router and set up routes so your /showAll would be different route and would resolve different parameters.
This would be your main route: http://myURL.com
and this would take some parameter: http://myURL.com/:showParameter
then in resolve of second you can check if showParameter is showAll and resolve whatever you want - i.e. expose some show/hide variable.
Post a Comment for "Show Or Hide The Element Based On The User Input"