angular.js - angular(ionic)中 label标签包含的button按钮的click事件无效怎么办
ringa_lee
ringa_lee 2017-05-15 17:10:06
0
2
637

我的需求是这样的,想在搜索框中添加一个搜索的图标,能够点击搜索
于是我就按照思路一步步开始做,下面是我的代码

//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')
        }
}

写之后发现,点击按钮是无效的,不使用ionic或者angular环境是有效的,还有就是点击button 的时候光标会聚焦到搜索框,这是什么情况啊,求各路大神解答,万分感谢

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