此文章涉及到时1.X的版本。请注意!
1.关于checkbox和bootstrap不能选中BUG
在使用angularjs的时候,有个比较明显的bug ng-disabled无效的情况
这里是一种情况的bug
<div class="checkbox MLH-specval-item" toggle-class="selected" ng-class="{'selected':specV.selected == 1}" ng-disabled="{{specV.selected === 1}}" ng-click="toggleSpec(specInfo.k, specV.v)">
<i></i>
<span>{{specV.v}}</span>
</div>
这种情况下ng-disabled 是无效的,解决办法
<input type="checkbox" class="checkbox MLH-specval-item" toggle-class="selected" ng-checked="{{specV.selected === 1}}" ng-disabled="{{specV.selected === 1}}" ng-click="toggleSpec(specInfo.k, specV.v)">
就直接使用原有的控件,不适用angularjs 的 class="checkbox MLH-specval-item",还有其他的也有类似的情况,比如button按钮,无法使用
也可以使用类似方法,直接使用原生控件,在加上bootstrap的样式
这可能是angularjs和bootstrap混合使用出现的BUG,底层原因没有追查,毕竟 我是个后台开发
2.ng-model赋值触发ng-click,ng-focus事件
<input type="text" class="inp-write" ng-model="shop_name" ng-change="changeName()" ng-click="selectedShow=true" placeholder="请输入名称">
在此场景里在text框,点击响应 selectedShow=true,显示一个 ng-model="selectedShow" 的div,但是在给ng-model="shop_name" $scope.shop_name = item.name
赋值的会再次激活ng-click和ng-focus方法,ng-focus我还可以理解,但是为什么要激活ng-click,就有点奇怪,如果要实现点击text框,显示一个下拉框就得使用
ng-mouseenter="selectedShow=true" ng-mouseleave="selectedShow=false"
只能使用这个方法才能不出bug