javascript - Use data in view from controller from ng-click angular -
pretty new angular , having little trouble getting data controller , displaying in view using ionic.
i have function in controller ('dashctrl') pass through string use within function using ng-click. want take string , display in next view have href on same element have ng-click event.
when log string on next page, working , shows up. how use in view?
heres code:
html
*first page
<ul contentful-entries> <div ng-repeat="story in $contentfulentries.items"> <li class="story col col-100"> <a href="#/tab/story/{{story.fields.slug}}" ng-click='storydetails("{{story.fields.title}}")'> <p>{{ story.fields.title }}</p> </a> </li> </div> </ul>
*redirects on ng-click
<ion-view view-title="story"> <ion-nav-buttons side="left"> <button class="button back-button buttons button-clear header-item" ng-click="goback()"> <i class="icon ion-ios-arrow-back"> back</i> </button> </ion-nav-buttons> <ion-content> <ion-list ng-controller="dashctrl"> <h1>{{ story.slug }} </h1> <p> <!-- here want display string --> </p> </ion-list> </ion-content> </ion-view>
*heres controller
.controller('dashctrl', function($scope, $stateparams, $ionichistory) { $scope.storydetails = function($scope, details) { // here data need display in view // console.log shows in browser console.log(details); } $scope.goback = function(){ $ionichistory.goback(); } // working fine $scope.story = $stateparams; })
save details string controller variable, , can access within view.
Comments
Post a Comment