大佬教程收集整理的这篇文章主要介绍了angularjs – Angular TypeError:name.replace不是ng-style的函数,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<div class="system-view"> <div class="controller-container fill" id="systemView1" ng-style="isFrontView() || !matches && {'display': 'none'}"> <canvas id="canvasLayer-sHell" data-layername="front" width="617" height="427"></canvas> <i ng-if="!matches" class="fa fa-repeat toggle-view" ng-click="changeView()" ng-touch="changeView()"></i> </div> <div class="controller-container fill" id="systemView2" ng-style="!isFrontView() || !matches && {'display': 'none'}"> <canvas id="canvasLayer-sHell" data-layername="BACk" width="617" height="427"></canvas> <i ng-if="!matches" class="fa fa-undo toggle-view" ng-click="changeView()" ng-touch="changeView()"></i> </div> </div>@H_262_1@后端代码:
$scope.frontView = true; $scope.matches = true; $scope.isFrontView = function() { return $scope.frontView; }; $scope.changeView = function() { $scope.frontView = !$scope.frontView; };@H_262_1@附:即使控制台出错,一切仍然正常.
ng-style
sets a watcher on the expression并设置
element’s style with the help of jquery/jqlite element.css
.并且inside element.css css属性(Name)被转换为标准的驼峰套管(
which uses regex string replace).在您的特定情况下,表达式求值为Boolean(true)而不是对象(
ng-style
does this for each property),Boolean没有replace属性(在字符串对象上可用),因此失败.您可以通过使用字符串连接将表达式转换为求值来测试此值.
@H_262_1@即ng-style =“”(isFrontView()||!匹配&& {‘display’:’none’})”
@H_262_1@查看表达式所有你需要它来隐藏和显示元素,你可以使用ng-show
/ng-hide
指令来实现这一点.
以上是大佬教程为你收集整理的angularjs – Angular TypeError:name.replace不是ng-style的函数全部内容,希望文章能够帮你解决angularjs – Angular TypeError:name.replace不是ng-style的函数所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。