Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
How to accessing the input value of <ons-search-input ></ons-search-input>
-
Hello Developers,
Please I have been trying to access the value that is put in the input of this search element (<ons-search-input placeholder=“Search”></ons-search-input>). How do I access it please?
The view
<ons-page ng-controller="SearchController as search"> <ons-toolbar> <div class="left"><ons-back-button ng-click="splitter.load('home.html')"></ons-back-button></div> <div class="center">Search</div> </ons-toolbar> <p style="text-align: center; margin-top: 120px"> <ons-search-input ng-keyup="search.takeaction()"></ons-search-input> </p> </ons-page>
Here is the controller
var module = angular.module('my-app', ['onsen','ngSanitize']); module.controller('SearchController', function($http, $scope) { console.log('we got the search'); this.takeaction = function(value) { alert('fxn called'); var searchkey = this.value; console.log(searchkey); } });
This displays ‘undefined’ for console.log(searchkey); on the view when the function is called. Someone should help me out please. Thanks in advance