我已经创建了一个简单的指令,生成一个svg indeterminate微调。包含在页面中的脚本运行良好。 svg和脚本完美地生成。脚本不会触发。脚本从指令添加到dom不发射
我this plunk of the generated output
<svg width="64" height="64" viewBox="0 0 64 64">
<g transform="translate(32, 32)">
<circle id="myId"
fill="none"
stroke="#000000"
opacity=".8"
stroke-width="5"
stroke-linecap="round"
stroke-miterlimit="10"
cx="0" cy="0" r="29.5"
>
</circle>
</g>
</svg>
<script>
var line = document.getElementById("myId");
var initialTheta = 0;
var thetaDelta = 1;
myId.currentTheta = initialTheta;
var requestAnimationFrameID = requestAnimationFrame(doCircAnim);
function doCircAnim() {
myId.setAttribute("transform", "rotate(" + myId.currentTheta + ")");
myId.setAttribute("stroke-dasharray", myId.currentTheta);
myId.currentTheta += thetaDelta;
if(myId.currentTheta > 180){ myId.currentTheta = 0}
requestAnimationFrameID = requestAnimationFrame(doCircAnim);
}
</script>
展示正确的行为,它应该作为一个独立的单元工作 - 这确实。这是由不与plunk链接的指令生成的,但它应该是不言自明的。动画脚本从Microsoft's svg animation starter page中解脱出来,因为它是所有必需的(经过几次调整)。
我试过了一大堆事情,要么没有成功,要么一批新的错误,然后失败。我确信这件事已经以某种形式回答了,所以如果它已经接受我的道歉,但我没有找到解决办法。
在此先感谢。
新普拉克基于原有的表现行为 Running directive with options
(function(){
'use strict';
angular.module('loader', [])
.directive('loader', ['$window', function($window){
return {
restrict: 'E',
link: function (scope, element, attrs){
...
}
}
}
})();
你试过window.requestAnimationFrame(doCircAnim)吗? – GavinBrelstaff
我会给它一个回去,回来...没有没有工作。 :( –
你也许正在遭受这种bug的影响http://stackoverflow.com/questions/24078366/angularjs-directive-not-displaying-the-template – GavinBrelstaff