reload state when you are on same state in angular ui-router

angular-ui-router, angularjs, javascript, ngroute, routes

Solution

add attribute to the element with

ui-sref=""ui-sref-opts="{reload:true}"

example:

<a ui-sref-opts="{reload:true}" ui-sref="app.post.applicants">Applicants</a>

Problem

My Question is can we reload the view in ui-router if you are on same state. check my code at`http://plnkr.co/edit/MA7CuyH2RFrlaoAgBYog?p=preview My app.js file is ``` var app = angular.module('plunker', ['ui.router']); app.config(function($stateProvider) { $stateProvider .state("view1", { url: "/view1", templateUrl: "x.html" }) .state("view2", { url: "/view2", templateUrl: "y.html" }) }) app.controller("MainCtrl",function(){}); ``` And index page is ``` <body ng-controller="MainCtrl"> <a href="#/view1">Accounts</a> <a href="#/view2">Dashboard</a> <div ui-view></div> ``` Now click on Dashboard link here you will see a text box. fill any value in that. Now again click on Dashboard link. now the state should reload and all data of page should be reloaded including its controller. Please make sure to ui-router only. Thanks

Original source

Related problems