How to ng-hide and ng-show views using angular ui router?

后端 未结 4 1142
有刺的猬
有刺的猬 2020-12-08 00:30

Imagine an application has a List page, such as a table showing a list of users. There is a button on each row of the table called \"Edit\", and when this is clicked, a righ

4条回答
  •  有刺的猬
    2020-12-08 00:59

    Your url must reflect the state mode using querystring: /stuff/1?edit or /stuff/1 that stands for /stuff/1?view

    You could use reloadOnSearch=false to instruct AngularJS not to reload the view:

    http://docs.angularjs.org/api/ngRoute.$routeProvider

    Inside your controller, check the state mode (view or edit) using $routeParams. Catch the edit click event, pass your model to your bar and toggle its visibility accordingly.

    See those interesting links:

    Can you change a path without reloading the controller in AngularJS?

    Updating URL in Angular JS without re-rendering view

提交回复
热议问题