I have an AngularJS app that uses ui-router to manage my app's states and URL routing.
Here is a sample state:
.state('my_state', {
url: '/my_state/:arg1',
templateUrl: 'http://www.example.com/html/my_file.html',
controller: 'MyCtrl'
})
Here is it's controller:
app.controller('MyCtrl', function($stateParams) {
console.log('arg1 = ', $stateParams.arg1)
);
Here is how I send people to it from within another controller:
$state.go('my_state', {'arg1': 'hello'});
When the $state.go line above is executed, I get sent to this URL /my_state/hello and I see the following printed to the browser's debug window:
arg1 = hello
Now here is my question: Can I add another argument to this controller such that:
- It is named
arg2. - It is optional.
- If provided, it can be accessed inside
MyCtrl. - It does not show up in the URL.
If so, please show me how.