0

I am working with angular router in my application and i have a scenario where i want to show/hide states based on some conditions. My scenario is that

  1. Show privacy screen if the privacy policy is revised (show terms-changes & terms screen).
  2. Show terms of use page if the terms of use is revised (show privacy-changes & privacy screens).
  3. Show both screens if both have changed(show all 4 screens).

JS

angular.module("portal").config(["$stateProvider", "$urlRouterProvider", function($stateProvider, $urlRouterProvider) {
   $urlRouterProvider.otherwise('/terms-changes');
    $stateProvider
    .state('terms-changes', {
        url: '/terms-changes',
        templateUrl: 'policy/terms-changes.jsp'
    }).state('terms', {
        url: '/terms',
        templateUrl: 'policy/terms-conditions.jsp'
    }).state('privacy-changes', {
        url: '/privacy-changes',
        templateUrl: 'policy/privacy-changes.jsp'
    }).state('privacy-policy', {
        url: '/privacy-policy',
        templateUrl: 'policy/privacy-policy.jsp'
    });
}]); 

How will i be able to show these screens based on the conditions. i dont want to show the whole screen, say for example if only privacy policy is changed.

Sha
  • 1,826
  • 5
  • 29
  • 53
  • this is a true duplicate of http://stackoverflow.com/questions/13681116/angularjs-dynamic-routing – ymz Feb 16 '17 at 11:35
  • 1
    @ymz This is for `ui-router` whereas your link refers to `ngRoute`. – Matthew Cawley Feb 16 '17 at 11:38
  • @Shereer how do you determine that either have changed? (changed from what?) – Matthew Cawley Feb 16 '17 at 11:42
  • 1
    @Matthew - many thanks.. I haven't notice that. good thing we also have github to the rescue https://github.com/angular-ui/ui-router/issues/163 – ymz Feb 16 '17 at 11:55
  • @matthew i will have a key appended with the url to determine what have changed. i need to get it from the url and do the check. – Sha Feb 16 '17 at 12:05

0 Answers0