Error: $digest already in progress
by programmieraffe
HTML
<script src="http://docs-next.angularjs.org/angular-0.10.6.min.js" ng:autobind></script>
<div ng:app>
<div ng:controller="MyCtrl">
<ui:example></ui:example>
{{clickCount}}
</div>
</div>
JavaScript
// originally from https://github.com/twarogowski/angular-contrib/blob/master/js/angular-widgets.js
var widgetUtils = {
setValue: function (scope, attrExpr, value){
if(!attrExpr || !attrExpr.expression)
return;
var v = value;
v = this.parseValue(v, attrExpr, scope);
// the way it was:
// scope.$set(attrExpr.expression, v);
// my approach:
scope.$apply(scope[attrExpr.expression] = v);
}
}
angular.widget('ui:example',function(el){
el.append();
var compiler = this;
return function(htmlEl) {
console.log(htmlEl);
$(element).append('<button>Test</button>');
$(element).on('click',function(){
});
}
});
function MyCtrl(){
this.clickCount = 0;
}
MyCtrl.$inject = [];