vendredi 1 juillet 2016

How to alert a view to show data

I am new to angularjs. I just started creating a sample application. Please help me with your suggestions.

Below is my sample application.

Sample application

Below are the pages created:

  1. page --> Notes.cshtml / notesController.js
  2. NotesList --> NotesList.cshtml / notesListController.js
  3. AddNote --> AddNote.cshtml / addNotecontroller.js
  4. ViewNote --> ViewNote.cshtml / viewNoteController.js

When user select a note from the noteslist, i want to load details on the right side (in ViewNote.cshtml). Please note that i can show only Add Note or View Note at a time.Hence, i am using ng-show to show/hide respective partial controls.

My question:

  1. When i click on a note from notes list, im calling server to fetch note details using a service.js. I understand that, the best way to share data b/w controllers is using a service. Hence, i kept the fetched data in service object.
    1. Now, i want to intimate view.cshtml to load the fetched data.
    2. Should i use $emit or $broadcast in service.js to intimate ViewNoteController.js ?
    3. I have service object injected into ViewNoteController.js

Is there a better way of handling this scenario? Pls suggest.

Aucun commentaire:

Enregistrer un commentaire