Having trouble using Angular's ng-model to store and pass values with ng-click? If you're receiving undefined values in your current code, here's a possible solution. Check out the HTML snippet below:
HTML
<ion-content>
<div class="list">
<label class="item item-input">
<textarea ng-model="feedback.comment"></textarea>
</label>
</div>
</ion-content>
<div class="tabs tabs-icon-left">
<a class="tab-item" ng-click="submitFeedback(feedback)">
<i class="icon ion-arrow-right-b"></i>
</a>
</div>
JavaScript - Controller
.controller("FeedbackController", function($scope, $http, $localStorage){
$http.get("https://api.example.com/data", { params: { access_token: $localStorage.token, fields: "id, location, picture", format: "json" }}).then(function(response) {
$scope.userData = response.data;
console.log(response.data);
}, function(error) {
alert("Error fetching user data");
console.log(error);
});
$scope.submitFeedback = function(data){
console.log(data);
}
});
Routes
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home')
$stateProvider
.state('home', {
url: '/',
templateUrl: 'templates/home.html',
controller: 'HomeController'
})
.state('profile', {
url: '/profile',
templateUrl: 'templates/profile.html',
controller: 'ProfileController'
})
.state('dashboard', {
url: '/dashboard',
templateUrl: 'templates/dashboard.html',
controller: 'DashboardController'
})
.state('feedback', {
url: '/feedback',
templateUrl: 'templates/feedback.html',
controller: 'FeedbackController'
})
})