Trigger state in button tag using ui-sref
Wrap the button in an anchor and you are good to go: <a ui-sref=”main”> <button class=”btn btn-danger navbar-btn” >Button Submit</button> </a> DEMO
Wrap the button in an anchor and you are good to go: <a ui-sref=”main”> <button class=”btn btn-danger navbar-btn” >Button Submit</button> </a> DEMO
Add pathMatch: ‘full’ {path: ”, component: AppComponent, pathMatch: ‘full’}, to routes with empty path ” and no child routes.
There is a plunker showing how we can configure the views dynamically. The updated version of the .run() would be like this: app.run([‘$q’, ‘$rootScope’, ‘$state’, ‘$http’, function ($q, $rootScope, $state, $http) { $http.get(“myJson.json”) .success(function(data) { angular.forEach(data, function (value, key) { var state = { “url”: value.url, “parent” : value.parent, “abstract”: value.abstract, “views”: {} }; // … Read more
I think the best way of doing this would be to use ng-switch, just one controller, one route, no reload, using variables shared in all steps, like this: <div ng-controller=”stepCtrl”> <div ng-switch=”step”> <div ng-switch-when=”1″> <!– here you can include your step 1 template, or simply just hardcode it here: –> <div ng-include src=”‘…/step1.html'”> <button ng-click=”setStep(1)”></button> … Read more
It’s intuitive to think of a modal as the view component of a state. Take a state definition with a view template, a controller and maybe some resolves. Each of those features also applies to the definition of a modal. Go a step further and link state entry to opening the modal and state exit … Read more
Use ui-sref-opts. Here you go: <a ui-sref=”app.editPost({new:true})” ui-sref-opts=”{reload: true, notify: true}”>new post</a> https://ui-router.github.io/ng1/docs/0.3.1/index.html#/api/ui.router.state.directive:ui-sref
You can’t pass arbitrary parameters between states, you need to have them defined as part of your $stateProvider definition. E.g. $stateProvider .state(‘contacts.detail’, { url: “/contacts/:contactId”, templateUrl: ‘contacts.detail.html’, controller: function ($stateParams) { console.log($stateParams); } }) … The above will output an object with the contactId property defined. If you go to /contacts/42, your $stateParams will be … Read more
The way I find the ui-router exceptional, is in the behaviour you’ve just described. Let’s think about some entity, e.g. Contact. So it would be nice to have a right side showing us the list of Contacts, the left part the detail. Please check the The basics of using ui-router with AngularJS for quick overvie … Read more
Sounds like you simply don’t want the views to be hierarchical. To do this, simply change the name of the second state to detail. Note however, that in doing so you will lose any hierarchical properties of the state tree (the controller code state of accounts for example). If you want to keep the controllers … Read more
The issue here would be related to this Q & A: How do I share $scope data between states in angularjs ui-router?. The way how to solve it is hidden in the: Understanding Scopes In AngularJS, a child scope normally prototypically inherits from its parent scope. … Having a ‘.’ in your models will ensure … Read more