angularjs - Controller is not being reset after href call -


i have angularjs controller in ionic framework.

.controller('locationdetailctrl', ['$scope','$cordovageolocation','$cordovacamera', '$cordovafile','$stateparams','location', locationdetailctrl]);      function locationdetailctrl ($scope, $cordovageolocation, $cordovacamera, $cordovafile, $stateparams, location) {         $scope.locationrow = {};         $scope.test = "";          $scope.images = [];             location.getbyid($stateparams.locationid).then(function(result){           //alert("i'm in");           $scope.locationrow = result;         });                 } 

i have code in view somewhere this:

<ion-item class="item-remove-animate item-icon-right" ng-repeat="location in locations" type="item-text-wrap" href="#/locations/{{location.id}}/all">     <h2>{{ location.aplicant_name}}</h2>     <p>{{ location.form_type }}</p>     <i class="icon ion-chevron-right icon-accessory"></i>     <ion-option-button class="button-assertive" ng-click="remove(location)" translate>delete</ion-option-button> </ion-item> 

in stateprovider have this:

.state('location-detail', {       url: '/locations/{locationid}',       abstract: true,           templateurl: 'templates/location-detail.html',       controller: 'locationdetailctrl'     }) .state('location-detail.all', {      url: '/all',      views: {          'loc-detail-view': {              templateurl: 'templates/location/location-map-all.html'          }      }  }) 

my problem is, on first href click values database, alright. when go , press list time, same value got earlier.

turns out location.getbyid() not being called second time around.

never-mind, found answer. turns out controller being cached default.

i modified state provider code , refreshes view new model.

  .state('location-detail', {       url: '/locations/{locationid}',       cache: false,       abstract: true,       templateurl: 'templates/location-detail.html',       controller: 'locationdetailctrl'   }) 

the difference here cache:false.

cheers!


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -