Javascript 如何在AngularJS中使用Cufon

Javascript 如何在AngularJS中使用Cufon,javascript,angularjs,cufon,Javascript,Angularjs,Cufon,我正在做一个和angularJs一起工作的项目,我用Cufon来改变字体。 现在,当控制器加载时,cufon替换角度表达式,然后angularJs将运行。 那是我的问题。 我希望Cufon在角度表达式绑定后运行。 有人能帮我吗 在我的HTML页面中: <span class="input-label" id="lb" >{{s}}</span> 问题是在角度绑定发生之前,Cufon更改表达式值的位置 有人能帮我吗?您可能需要使用指令并收听元素以准备就绪:

我正在做一个和angularJs一起工作的项目,我用Cufon来改变字体。 现在,当控制器加载时,cufon替换角度表达式,然后angularJs将运行。 那是我的问题。 我希望Cufon在角度表达式绑定后运行。 有人能帮我吗

在我的HTML页面中:

        <span class="input-label" id="lb" >{{s}}</span>
问题是在角度绑定发生之前,Cufon更改表达式值的位置


有人能帮我吗?

您可能需要使用指令并收听元素以准备就绪:

html:

为cufon更新:

function MyController($scope) {

  $scope.content = [
    'param1', 'param2'
  ];
}

angular.module('myApp', [])
  .directive('cufonReplaceDirective', function() {
    return function(scope, element, attrs) {
        scope.content = ["somecontent123"]
        element.ready(function(){
          Cufon.replace('.thing', {onAfterReplace: Bifon.convert, fontFamily: 'B Titr'});
        })
    };
});

工作得很好,cufon真的变老了,有着沉重的js文件
<div ng-controller="MyController">
    <div class="thing" ng-bind="content" cufon-replace-directive>
        content {{content}}
    </div>
</div>
function MyController($scope) {

  $scope.content = [
    'param1', 'param2'
  ];
}

angular.module('myApp', [])
  .directive('cufonReplaceDirective', function() {
    return function(scope, element, attrs) {
        element.ready(function(){
          element.html(element.html().replace(/[0-9]/g,"!!!"))
        })
    };
});
function MyController($scope) {

  $scope.content = [
    'param1', 'param2'
  ];
}

angular.module('myApp', [])
  .directive('cufonReplaceDirective', function() {
    return function(scope, element, attrs) {
        scope.content = ["somecontent123"]
        element.ready(function(){
          Cufon.replace('.thing', {onAfterReplace: Bifon.convert, fontFamily: 'B Titr'});
        })
    };
});