3

In my application, am loading views using ngRoute,

 .state('ReportViewer', { url: "/ReportViewer", controller: 'ReportViewerControl', templateUrl: "views/Report_viewer.html" }) 

I have a search Panel where users can search reports, and when selecting a report, it should route to a different page and load the report inside an iframe. Here is my code when the user select the report,

 $scope.goReport = function(report){ $state.go('ReportViewer'); } 

I have defined a constant in the config which changes dynamically based on the report selection

 .constant('Digin_ReportViewer','http://192.226.192.147:8080/api/repos/%3Ahome%3Aadmin%') 

Here i need to pass the 'Report' variable to the ReportViewerControl when the user select the report,

Here is my ReportViewerControl

 routerApp.controller('ReportViewerControl', ['$scope', '$routeParams','Digin_ReportViewer',function($scope, $routeParams,Digin_ReportViewer) { //here i need to append the report url , $scope.reportURL = Digin_ReportViewer+routeParams.report ; $scope.trustSrc = function(src) { return $sce.trustAsResourceUrl(src); } } ]); 

1 Answer 1

2

you are using ui-router for confiuring routes ,but below in ReportController you are using $routeParams.I hope you have to use $stateParams for that.

 routerApp.controller('ReportViewerControl', ['$scope', '$stateParams','Digin_ReportViewer',function($scope, $stateParams,Digin_ReportViewer) { //here i need to append the report url , $scope.reportURL = Digin_ReportViewer+stateParams.report ; $scope.trustSrc = function(src) { return $sce.trustAsResourceUrl(src); } } ]); 

also you have to pass the params from url or in method like this

.state('ReportViewer', { url: "/ReportViewer", controller: 'ReportViewerControl', templateUrl: "views/Report_viewer.html", params: ['report'] }) 

Then you can navigate to it like so:

$scope.goReport = function(report){ $state.go('ReportViewer', { 'report':'monthly' }); } 

Or:

var result = { 'report':'monthly' }; $state.go('ReportViewer', result); 
Sign up to request clarification or add additional context in comments.

3 Comments

TypeError: a.match is not a function
Can u describe the problem or error you are facing?
This is the error, am getting Uncaught Error: [$injector:modulerr] Failed to instantiate module DiginRt due to: TypeError: a.match is not a function at k (cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/…)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.