how to change template in controller angularjs

Viewed 22

I am trying to generate the template for the state in the dynamically with the controller as follows:

app.config( function($stateProvider, $urlRouterProvider) {
                            
                                $urlRouterProvider.otherwise('/');
                                
                                $stateProvider
                                    .state('home', {
                                        url: '/',
                                        templateUrl:'homeView.html',
                                        controller: 'homeController'
                                    })                                  
                                    .state('review', {
                                        url: '/pendingPaymentReview',
                                        template: null,
                                        templateProvider: function($stateParams){
                                                                return $stateParams.template;
                                                            },
                                        controller: 'reviewController'
                                    });

And then define the controllers as:

app.controller('reviewController', function ($scope, tempData, $stateParams) {

                            var template = tempData.getTemptlate(); 
                            $stateParams.template = template; 
                            alert($stateParams.template);

tempData is a service that retrieves the page fragment from the server using $http. My question is how do modify access and modify the template parameter of the review state? I have tried using $stateParams but got no display page. Any help will be more than appreciated.

0 Answers
Related