Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic - AngularJS - How do you go about refreshing the view state on click.

        <a href="#/assessments/{{assessment.id}}">
            <div class="item item-divider">
                <h2>{{assessment.test.name}}</h2>
                <p>{{assessment.test.items.length}} questions</p>
            </div>
            <div class="item item-text-wrap item-icon-right">
                {{assessment.test.introduction}}
                <i class="icon-next icon"></i>
            </div>
        </a>

I need to pull through the id for each anchor that is created in a ng-repeat and then before it gets to the next state I need it to refresh the state instead of just loading the data. Is there a way to not do this in the controller?

like image 585
Max Lynn Avatar asked Dec 12 '25 21:12

Max Lynn


1 Answers

You can try this:

<a ui-sref="assessments({id: assessment.id, reload: true})">
  <div class="item item-divider">
    <h2>{{assessment.test.name}}</h2>
    <p>{{assessment.test.items.length}} questions</p>
  </div>
  <div class="item item-text-wrap item-icon-right">
    {{assessment.test.introduction}}
    <i class="icon-next icon"></i>
  </div>
</a>

Then have this in your stateProvider:

.state('assessments', {
  url: '/assessments/:id',
  templateUrl: 'assessments.html',
  controller: 'assessmentsController'
});
like image 97
thepio Avatar answered Dec 15 '25 13:12

thepio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!