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});    
 });
};
5
  • does both views access same controller? Commented Jan 4, 2017 at 7:20
  • Yes you are right, same controller. Commented Jan 4, 2017 at 7:21
  • check whether you mentioned the controller for workshop_d.html in routing... Commented Jan 4, 2017 at 7: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. Commented Jan 4, 2017 at 7:25
  • 1
    Controllers are disposed when changing routes. Try to use different controller if possible. Check this schenker stackoverflow.com/questions/16210822/… Commented Jan 4, 2017 at 7:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.