1

I want send parameter to templateUrl i want append some numbers after /folder/stockInventoryController.do?param=loadGroupStyles_Controller&fabId=(here I need to add)

    myApp.config(function($routeProvider){
        //setup Router for widgets page
        $routeProvider
        .when('/relatedStyle',{
            controller:'groupStylesLoad',
            templateUrl:'/folder/stockInventoryController.do?param=loadGroupStyles_Controller&fabId='+needParameterHere
        })
    });
TechnoCrat
  • 710
  • 10
  • 20
Naresh
  • 19
  • 9

3 Answers3

0

templateUrl can be used as a function if you need to work some magic on the url. It accepts 1 parameter which takes in the current url.

Looking at your example, there aren't any parameters in /relatedStyle; but if there were you'd access and modify them like so:

.when('/relatedStyle/:arbitraryParam',{
        controller:'groupStylesLoad',
        templateUrl: function(url) {
            var modifiedParam = url.arbitraryParam++;
            return '/folder/stockInventoryController.do?param=loadGroupStyles_Controller&fabId=' + modifiedParam;
        }
    })
Matt
  • 3,079
  • 4
  • 30
  • 36
0
http://stackoverflow.com/questions/11534710/angularjs-how-to-use-routeparams-in-generating-the-templateurl

see above link ,it may be helpful for u

0

Here are two ways. One is routing

myApp.config(function($routeProvider){
        //setup Router for widgets page
        $routeProvider
        .when('/relatedStyle/:fabid',{
            controller:'groupStylesLoad',
            templateUrl:'template/template.html'
        })
    });

myApp.controller("groupStylesLoad", ['$scope', '$routeParams',
     function($scope, $routeParams)
         {var fabId = $routeParams.fabid;}
]);

However, if you need to use the query sting.

 myApp.controller("groupStylesLoad", ['$scope', '$location',
         function($scope, $location)
             {var fabId = $location.search().fabid;
             // $location.search() returns object like {key1: value1, key2: value2, ...}
        ]);

https://docs.angularjs.org/guide/$location

Hope this helps.