angularjs - $Scope doesn't work on subpage -


this controller,

.state('tabs.urunler',{  		url:'/urunler',  		views:{  			'urunler-tab':{  				templateurl:'pages/urunler.html',          controller:'myctrl'  			}  		}  	})    .state('tabs.detail',{      url:'/urunler/:aid',      views:{        'urunler-tab' : {          templateurl:'pages/urunlerdetail.html',          controller : 'myctrl'        }      }    })

this post method.

$http({            url : apiaddress + 'geturunler',            method : 'post',            data : {type}          }).then(function successcallback(response){                $scope.urunler = response.data;              console.log($scope.urunler);          },function errorcallback(response){            console.log("error");          });

this urundetails.html

<ion-item ng-repeat="urun in urunler">                  {{urun.title}}                  <div class="list">                  	{{urun.brand}}                      <a class="item item-thumbnail-left">                          <img src ="{{urun.picture}}">                          <h2>{{urun.brand}}</h2>                          <p>{{urun.title}}</p>                      </a>                  </div> 

this urun.html

 <ion-item ng-repeat="urun in urunler">                  <div class="list">                        <a class="item item-thumbnail-left" ng-click="changeurun('alix avien')" href="#/tab/urunler/{{urun.title}}">                          <img src ="{{urun.picture}}">                          <h2>{{urun.brand}}</h2>                          <p>{{urun.title}}</p>                      </a>                  </div>                               </ion-item>

the problem , can reach {{urun}} in urun.html, when go subpage of urun.html urundetails.html, $scope doesn't work :/. i've looked response data after reached urundetails.html writing console.log(); data coming can not see data on urundetails.html page. !!

this issue because binding data scope variable outside angular scope digest cycle. scenario have manually trigger digest cycle.

there no. of ways trigger digest cycle manually.

i suggest use $timeout(function(){}, 0); after $scope.urunler = response.data. trigger digest cycle once more taking care of clashes if there digest cycle running.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -