使用Firefox的AngularJS插件 - " NG-SRC"不工作 [英] Firefox addon using AngularJS - "ng-src" not working

查看:370
本文介绍了使用Firefox的AngularJS插件 - " NG-SRC"不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工作的Firefox附加组件,使用AngularJS。
问题是'NG-SRC。它不会加载引用的图像。
当我切换到'src'中的图像加载罚款。

example.html的和图标32.png是同一个文件夹中。

鸭preciate你在做这个问题的意义上的帮助。

下面是code片段。

example.html的

 < HTML NG-应用=MyAddonNG-CSP>
    < HEAD>
    < /头>
    <机身NG控制器=MainCtrlDIR ={{DIRR}}>
        < D​​IV边界=0>
            < IMG NG-SRC ={{标识}}WIDTH =32ALIGN =中心>
            <输入ID =文本框类型=文本> < /输入>
            <按钮ID =textboxbutton类型=按钮> {{ButtonText}}< /按钮>
        < / DIV>    &所述; SCRIPT SRC =LIB / angular.min.js>&下; /脚本>
    <脚本SRC =脚本/ app.js>< / SCRIPT>
    < /身体GT;
< / HTML>

app.js:

 函数MainController($范围){
    $ scope.ButtonText ='打我!;
    $ scope.dirr ='RTL';
    $ scope.logo ='图标32.png';
};VAR MyModule的= angular.module('MyAddon',[])
.controller('MainCtrl',MainController)


解决方案

这是因为角度不断加入不安全:到图像的URL。我认为这是解决方案,请尝试:<一个href=\"http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page\">Angular修改URL到&QUOT;不安全:&QUOT;在扩展页面

和白名单的资源:// 的URL。没有不安全:它的工作原理

我看到这个使用DOM查看器:

I am working on a Firefox add-on that uses AngularJS. The issue is with 'ng-src'. It does not load the referenced image. When I switch to 'src' the image loads fine.

Example.html and 'icon-32.png' are within same folder.

Appreciate your help in making sense of this issue.

Below are the code snippets.

Example.html

<html ng-app="MyAddon" ng-csp>
    <head>
    </head>
    <body ng-controller="MainCtrl" dir="{{dirr}}">
        <div border="0">
            <img ng-src="{{logo}}" width="32" align="center">
            <input id="textbox" type="text"> </input>
            <button id="textboxbutton" type="button"> {{ButtonText}}</button>
        </div>

    <script src="lib/angular.min.js"></script>
    <script src="scripts/app.js"></script>
    </body>
</html>

app.js:

function MainController($scope) {
    $scope.ButtonText= 'Hit me!';
    $scope.dirr = 'rtl';
    $scope.logo= 'icon-32.png';
};

var MyModule = angular.module('MyAddon', [])
.controller('MainCtrl', MainController)

解决方案

It is because angular keeps adding unsafe: to your image url. I think this is the solution, please try: Angular changes urls to "unsafe:" in extension page

and whitelist the resource:// urls. without unsafe: it works.

I saw this from using DOM Inspector:

这篇关于使用Firefox的AngularJS插件 - &QUOT; NG-SRC&QUOT;不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆