However, when I look at my $state or $stateParams object in my userController I donât have any of the data I passed in with the $state.go call. Any idea on how to pass that data to my login template??
hmm this solution doesnât really work, because I wonât always pass in an experience id.
I was thinking that when I did $state.go I can simply pass in an extra array thatâs not linked to the routing. If you have any experience with native Android, then I guess a comparable concept is passing a bundle.
@compudaze thanks this actually worked!!
The only thing is, I kept getting an error that said: Both params and url specicified in state 'login' . I got rid of the url so now my state looks like this:
Not sure why I got that error though? Any ideas?
Also, this brings up the issue, that I donât necessarily always want to pass experience_id. Just if that is set I want to do a different action in my controller. Any ideas on how to make that parameter optional?
ah actually nevermind, the reason my route didnât work is because I tried going to /login in the url bar, but since I had to remove the url: â/loginâ it didnât recognize it.
Here is a great reference if youâre struggling on how to pass a parameter to the state. It shows how you define the parameter in the state as well as calling the state using $state.go. This is pretty straight forward as there is 2 parameters to $state.go. Param 0 is the state. Param 1 is the javascript object with the property names being the parameter name as you defined them in the state definition.
Iâve got this same issue, not sure whatâs causing it. I canât get of square one with parameters because adding params to the state declaration instantly breaks the app.
My error is:
Uncaught Error: [$injector:modulerr] Failed to instantiate module westBay due to:
TypeError: id.match is not a function
at getArrayMode (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:39257:39)
at new Param (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:39230:21)
at http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:39863:39
at forEach (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:9022:20)
at Object.stateBuilder.ownParams (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:39862:7)
at registerState (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:39981:72)
at $StateProvider.state (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:40466:5)
at $StateProvider.IonicModule.factory.config.$stateProvider.state (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:46208:31)
at http://localhost:1337/app/app.module.js:159:6
at Object.invoke (http://localhost:1337/assets/bower_components/ionic/js/ionic.bundle.js:12884:17)
http://errors.angularjs.org/1.3.13/$injector/modulerr?p0=westBay&p1=TypeErrâŚ37%2Fassets%2Fbower_components%2Fionic%2Fjs%2Fionic.bundle.js%3A12884%3A17)
Are you passing in an array as the parameter? I believe it must be a dictionary / js object ⌠You could just do {âsomethingâ: nullâ} and that should work.
This feature was added recently: Its called dynamic params - one need to pass { dynamic: true } for making the param take value which is sent as part of
Hello, Iâd faced a similar problem. I ended up with a working solution after a lot of googling and trial and test. Here is my solution which would work for you.
I have two controllers - searchBoxController and stateResultController and a parameter named searchQuery to be passed from a view having a search box to a view showing the results fetched from a remote server. This is how you do it:
Below is the controller from which you call the next view using $state.go()
.controller('searchBoxController', function ($scope, $state) {
$scope.doSearch = function(){
var searchInputRaw = $scope.searchQueryInput;
$state.go('app.searchResults', { searchQuery: searchInput });
}
})
Below is the state that would be called when the $state.go() gets executed: