0

I'm just starting ionic and angularJs, so far it has been good, but i have some problem now. Hope to get some help.

I have 2 views, list of workshops (workshops.html) and a detailed view of the selected workshop (workshop_d.html).

When i click on one of the workshops in the list, the ng-click will send the id to the controller. The controller will then grab the details of the workshop by means of rest api. I have no problem grabbing the details and printing to console, but i could not display the details in workshop_d.html. To simplify this problem, i assigned a static text, workshop_name to a scope variable and try displaying it and i still can't see the value. My simplified code is listed below. Pls tell me what am i missing. Thanks.

File: workshop_d.html

<h1>{{workshop_name}}</h1>

File: ws.js

$scope.workshop_detail_page=function(id){

$http.get(url+"/"+id).then(function(response){

//..do something..
//assign a test value to workshop_name   
$scope.workshop_name=“Workshop ABC”;   
$state.go('tabs.workshopdetail',{'wID':id});    
 });
};
Atul Sharma
  • 9,397
  • 10
  • 38
  • 65
schenker
  • 941
  • 3
  • 12
  • 25
  • does both views access same controller? – Sharmila Jan 04 '17 at 07:20
  • Yes you are right, same controller. – schenker Jan 04 '17 at 07:21
  • check whether you mentioned the controller for workshop_d.html in routing... – Sharmila Jan 04 '17 at 07:24
  • I did, in fact when i declare $scope.workshop_name right after the controller opening tags, i can display it in the view file. – schenker Jan 04 '17 at 07:25
  • 1
    Controllers are disposed when changing routes. Try to use different controller if possible. Check this schenker http://stackoverflow.com/questions/16210822/angular-js-views-sharing-same-controller-model-data-resets-when-changing-view – Sharmila Jan 04 '17 at 07:29

0 Answers0