Javascript 带角的无限摘要问题
因此,我试图使用控制器中的一些逻辑向ng repeat添加一个属性。我得到一个信息错误。我很确定我得到了错误,因为我试图在ng重复期间更改范围值,但我不确定如何解决我想要做的事情而不抛出错误 所以我通过一个ng重复来启动Impress。最后应该是这样的:Javascript 带角的无限摘要问题,javascript,angularjs,angularjs-scope,Javascript,Angularjs,Angularjs Scope,因此,我试图使用控制器中的一些逻辑向ng repeat添加一个属性。我得到一个信息错误。我很确定我得到了错误,因为我试图在ng重复期间更改范围值,但我不确定如何解决我想要做的事情而不抛出错误 所以我通过一个ng重复来启动Impress。最后应该是这样的: <div rotate="45"> <div rotate="90" <div rotate="135"> <div rotate="180" <div rotate="135"> <div
<div rotate="45">
<div rotate="90"
<div rotate="135">
<div rotate="180"
<div rotate="135">
<div rotate="90">
<div rotate="45">
<div rotate="0">
整个HTML:
<div id="impressContainer" class="pull-right" ng-style="middleStyle">
<div id="impress">
<div ng-repeat="demo in demos" data-x="{{(($index + 1) * 1000) + 5000}}" data-y="{{(($index + 1) * -1500) - 3000}}" data-z="{{(($index + 1) * 2000) + 80000}}" data-rotate="{{getRotate()}}" data-scale="3" initiate-impress=""
class="step top stepCSS">
<h1>{{demo.name}}</h1>
<img src="{{demo.logo}}" />
</div>
</div>
</div>
{{demo.name}
我不确定这是否是您想要的
如果有什么事,请告诉我
<div ng-view="">
<!-- ngRepeat: rotate in rotations --><div ng-repeat="rotate in rotations" data-rotate="0" class="ng-scope ng-binding">
inside rotate 0
</div><div ng-repeat="rotate in rotations" data-rotate="45" class="ng-scope ng-binding">
inside rotate 45
</div><div ng-repeat="rotate in rotations" data-rotate="90" class="ng-scope ng-binding">
inside rotate 90
</div><div ng-repeat="rotate in rotations" data-rotate="135" class="ng-scope ng-binding">
inside rotate 135
</div><div ng-repeat="rotate in rotations" data-rotate="180" class="ng-scope ng-binding">
inside rotate 180
</div><div ng-repeat="rotate in rotations" data-rotate="135" class="ng-scope ng-binding">
inside rotate 135
</div><div ng-repeat="rotate in rotations" data-rotate="90" class="ng-scope ng-binding">
inside rotate 90
</div><div ng-repeat="rotate in rotations" data-rotate="45" class="ng-scope ng-binding">
inside rotate 45
</div><div ng-repeat="rotate in rotations" data-rotate="0" class="ng-scope ng-binding">
inside rotate 0
</div><div ng-repeat="rotate in rotations" data-rotate="0" class="ng-scope ng-binding">
inside rotate 0
</div></div>
内部旋转0
内侧旋转45度
内侧旋转90度
内侧旋转135
内侧旋转180度
内侧旋转135
内侧旋转90度
内侧旋转45度
内部旋转0
内部旋转0
我最终不得不在如下指令中使用全局变量:
var expoRotate = 180;
var expoRotateUp = false;
var ATCExpo = angular.module('ATCExpo', [])
Module.directive('getRotate', function($window) {
return {
restrict: 'A',
link: function(scope, element, window) {
if ($window.expoRotate == 0 || $window.expoRotate == 180) {
$window.expoRotateUp = !$window.expoRotateUp
}
if ($window.expoRoateUp) {
$window.expoRotate += 45;
} else {
$window.expoRotate -= 45;
}
element.attr('data-rotate', $window.expoRotate)
}
};
})
谢谢大家的帮助 需要共享更多的代码,比如是什么驱动了你的重复,如果你在其他任何地方绑定rotate无限摘要意味着你在摘要周期中修改绑定属性的值,我在你共享的内容中没有看到。你有没有查看ng开关?我添加了整个控制器
var expoRotate = 180;
var expoRotateUp = false;
var ATCExpo = angular.module('ATCExpo', [])
Module.directive('getRotate', function($window) {
return {
restrict: 'A',
link: function(scope, element, window) {
if ($window.expoRotate == 0 || $window.expoRotate == 180) {
$window.expoRotateUp = !$window.expoRotateUp
}
if ($window.expoRoateUp) {
$window.expoRotate += 45;
} else {
$window.expoRotate -= 45;
}
element.attr('data-rotate', $window.expoRotate)
}
};
})