angular.js - angularjs ng-if元素切换问题
黄舟
黄舟 2017-05-15 16:52:36
0
2
612

目前在界面上有个多选框选择1或者0,主要就是ng-if判断01来切换展示不同的两个p,。
现在有个问题,每个p切换的时候另一个p总会短暂存在,使得切换有延迟效果不好~有什么好的办法么?~

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
世界只因有你

Are you sure the problem is caused by the ng-if directive? I built an example and didn't find any problems, and I didn't encounter any delays during development.

Test address: https://jsfiddle.net/mm0h7ves/

There is no reason to have delays in the UI, unless your script execution efficiency is too low or there are too many watchers on the page, causing the polling dirty check to be too slow

某草草

This is very simple. Before clicking to switch, just set the object output by the previous p to empty

$scope.use = function(status) {
            $scope.mycoupon = {};
            $scope.useFlag = status;
            mycouponService.getCouponsByMemberAndStatus(status, function(info) {
                $scope.mycoupon = info;
            });
        };
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template