0

I have a app with code i want to prettify with prettify.js, but i cant get the apply method to work with angular 1.2. However it works with 1.1.

Because i cannot load the prettify lib on the body load because of angular, i have tried creating a filter like this

App.controller('myCtrl', function($scope) {
    setTimeout(function() {
        $scope.text = "function apply() { return 'not working..'; }";
        $scope.$apply();
    }, 0);
});

App.filter('pretty', function(){
    return function(text) {
        return prettyPrintOne(text);
    }
})

And the HTML

<div ng-app="Knob" ng-controller="myCtrl">
    <pre ng-bind-html-unsafe="text|pretty"></pre>
</div>

Here the working fiddle: working fiddle.

When angular is changed to 1.2 apply breaks (or maybe something else?)

Failing fiddle (same code, updated angularjs ) broken fiddle

4

1 回答 1

2

问题不在于 $apply 不起作用,而在于 ng-bind-html-unsafe 已被删除。查看此答案以获取更多信息。

于 2014-02-20T20:11:46.730 回答