Base solution for your next web application
Open Closed

pass parameters between views #394


User avatar
0
cicciottino created

How to pass parametrs from a view that contains a list of items to a view used for edit that item? Simply passing the id of the entity on a link href? or using some javascript api exposed from "abp", or using something more structured like passing data while you activete a paticular "state" of the Angular UI routing component? Can you indicate me some "best practice" that you are used to adopt? Is there an example in your example project? in the "Simple Task Application" project i haven't found anything about it, can you give me a clue?

thanks a lot.


3 Answer(s)
  • User Avatar
    0
    behiunforgiven created

    Did you try $rootScope ?

  • User Avatar
    0
    hikalkan created
    Support Team

    Assume that you have a task list and a task edit page. And user clicks an item in the list to enter to the edit page. Then you should send id of the task via route parameter (in url).

    task list: <a class="postlink" href="http://yourdomain.com/tasks">http://yourdomain.com/tasks</a> task edit: <a class="postlink" href="http://yourdomain.com/tasks/edit/5">http://yourdomain.com/tasks/edit/5</a> (or simpler: <a class="postlink" href="http://yourdomain.com/tasks/5">http://yourdomain.com/tasks/5</a>)

    can be a good structure.

  • User Avatar
    0
    cicciottino created

    good!, i accomplished this configuring the state provider as follow (inside app.js)

    .state('poieditor', {
                        url: '/poieditor/:id',  //<--id parameter
                        templateUrl: '/App/Main/views/poi/editor.cshtml',
                        menu: 'PoiEditor'
    

    and injecting into the controller the relative "$stateParams" service in order to recover the parameter

    var _id = $stateParams.id;

    i fond out that the UI Angular router offers a great flexibility this is a nice article (can be useful to someone) [http://www.ng-newsletter.com/posts/angular-ui-router.html])

    thanks