【问题标题】:Using CoffeeScript, how would I go about creating an AngularJS controller that has ngSanitize?使用 CoffeeScript,我将如何创建一个具有 ngSanitize 的 AngularJS 控制器?
【发布时间】:2017-02-24 05:26:59
【问题描述】:

我正在尝试创建一个具有 ngSanitize 的 Angular 控制器,就像这里的示例 https://docs.angularjs.org/api/ngSanitize/service/$sanitize

但我不确定如何在 CoffeeScript 中执行此操作。

在文档中的示例中,这是使用 ngSanitize 创建控制器的方式。

angular.module('sanitizeExample', ['ngSanitize'])
       .controller('ExampleController', ['$scope', '$sce', function($scope, $sce)

这是我当前用 CoffeeScript 编写的控制器:

app = angular.module 'example'
app.controller 'exampleController', ($scope, widgetSrv)

如何将 ngSanitize 添加到此?

【问题讨论】:

    标签: angularjs coffeescript


    【解决方案1】:

    将控制器的第二行更改为:

    app = angular.module 'example', ['ngSanitize']
    

    【讨论】:

    • 我试过了,但它似乎破坏了整个页面。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-27
    • 1970-01-01
    • 2016-11-11
    • 2014-12-24
    • 2014-10-14
    • 1970-01-01
    相关资源
    最近更新 更多