angular.js - What should I do if the click event of the button button contained in the label tag in angular (ionic) is invalid?
ringa_lee
ringa_lee 2017-05-15 17:10:06
0
2
668

My needs are like this. I want to add a search icon in the search box and be able to click to search
So I started to do it step by step according to the idea. Here is my code

//myController
<label class="item item-input">
        <input class="cft-textField" type="text" placeholder="例:大闸蟹" >
        <button class="ctf-search-btn" ng-click="dianji()"></button>
</label>

angular.module('myApp',['ionic'])
        .controller('myController',myController);

    function myController($scope) {
        $scope.dianji = function () {
            console.log('hello')
        }
}

After writing, I found that clicking the button is invalid. It is effective without using ionic or angular environment. Also, when clicking the button, the cursor will focus on the search box. What is going on? Please give me some answers from all the experts. It’s very helpful. Thanks

ringa_lee
ringa_lee

ringa_lee

reply all(2)
曾经蜡笔没有小新

The label problem has nothing to do with the angular/ionic environment.
Put the button outside the label or replace the label with p

Peter_Zhu

It can be used
http://runjs.cn/code/3ynzz3jv

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template