如果您想了解在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?和angularng指令的知识,那么本篇文章将是您的不二之选。我们将深入剖析在使用AngularJS
如果您想了解在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?和angular ng指令的知识,那么本篇文章将是您的不二之选。我们将深入剖析在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?的各个方面,并为您解答angular ng指令的疑在这篇文章中,我们将为您介绍在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?的相关知识,同时也会详细的解释angular ng指令的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- 在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?(angular ng指令)
- angularjs – Angular $digest循环使Chrome 50眨眼
- angularjs – Angular Js路由谷歌Chrome问题
- angularjs – Angular – 我可以从角度应用程序外部广播消息吗?
- angularjs – angular.js chrome Access-Control-Allow-Origin
在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?(angular ng指令)
我有一堆内部图像(本地应用程序资源),它们遵循我想在ngRepeat中显示的模式.
我可以通过以下方式静态加载图像:
<img src="images/image1.png"/>
但是,当我尝试在这样的重复中使用它们时:
<div ng-repeat="item in myList"> <img ng-src="{{item.imageUrl}}"/> </div>
我得到每个图像的错误(尽管错误中的图像确实存在),如下所示:
Refused to load the image 'unsafe:chrome-extension://hcdb...flhk/images/image1.png' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:".
我已经能够使用ng-src和XHR成功加载外部资源.对于动态加载的内部资源,是否必须遵循相同的模式?
更新 – 另一个简单示例
从最简单的Chrome应用程序(https://github.com/GoogleChrome/chrome-app-samples/tree/master/hello-world)开始,以下内容将在Chrome应用程序之外(在浏览器中)运行,但不在Chrome应用程序中:
的index.html
<!DOCTYPE html> <html ng-app ng-csp> <head> <title>Hello World</title> <script src="js/angular.min.js"></script> <script src="js/test.js"></script> </head> <body ng-controller="Ctrl"> <img ng-src="{{imageUrl}}"/> </body> </html>
test.js
function Ctrl($scope) { $scope.imageUrl = 'hello_world.png'; }
Angular changes urls to “unsafe:” in extension page
Angular有一个白名单正则表达式,图像src url必须匹配才能更改src. chrome-extension:// url默认情况下不匹配,因此您必须更改它.浏览此处获取更多信息:
http://docs.angularjs.org/api/ng/provider/ $compileProvider
我添加了以下代码以允许chrome-extension // urls到白名单(使用其他stackoverflow问题答案中的代码):
angular.module('myApp',[]) .config( [ '$compileProvider',function( $compileProvider ) { var currentImgSrcSanitizationWhitelist = $compileProvider.imgSrcSanitizationWhitelist(); var newImgSrcSanitizationWhiteList = currentImgSrcSanitizationWhitelist.toString().slice(0,-1) + '|chrome-extension:' +currentImgSrcSanitizationWhitelist.toString().slice(-1); console.log("Changing imgSrcSanitizationWhiteList from "+currentImgSrcSanitizationWhitelist+" to "+newImgSrcSanitizationWhiteList); $compileProvider.imgSrcSanitizationWhitelist(newImgSrcSanitizationWhiteList); } ]);
angularjs – Angular $digest循环使Chrome 50眨眼
但是,我发现闪烁效果只发生在OS X上的Chrome 50上,即如果在OS X中的Firefox或Windows上的Chrome上打开列表时发生$摘要,我将看不到闪烁.
这会是Chrome的错误吗?如何防止这种影响?因为如果没有更改选项的元素,人们不希望看到< select>元素眨眼.
我正在研究一个可以用最少的代码在线看到效果的例子.我当前项目的一个例子如下.
<selectng-model="application.choiceOfTeams[0]" ng-options="team.name for team in teams"> <option value="">-- select team --</option> </select> <selectng-model="application.choiceOfJobs[0]" ng-show="application.choiceOfTeams[0].jobs" ng-options="job.name for job in application.choiceOfTeams[0].jobs"> <option value="">-- select position from {$application.choiceOfTeams[0].name $} --</option> </select>
它似乎是这个错误:
https://bugs.chromium.org/p/chromium/issues/detail?id=613885
正如评论中所建议的,在select上设置转换为none已经解决了这个问题,在我的情况下(使用bootstrap)使用以下方法:
select.form-control { transition: none; }
要在没有引导程序的情况下使用,或者在不使用.form-control类的情况下使用,只需删除.form-control选择器并确保其他任何内容都不会覆盖select元素的transition属性:
select { transition: none; }
angularjs – Angular Js路由谷歌Chrome问题
代码1
的index.html
<!DOCTYPE html> <html> <head> <title>Test</title> </head> <body ng-app="plunker"> <div ng-view=""></div> <script src="angular.min.js"></script> <script src="angular-route.js"></script> <script src="app.js"></script> </body> </html>
app.js
var app = angular.module('plunker',['ngRoute']); app.config(function ($routeProvider) { $routeProvider.when('/login',{ controller: '',templateUrl: 'login.html' }).otherwise({ redirectTo: '/login' }); });
的login.html
Hello from login!
码2
所有其他事情都与app.js中的更改相同
var app = angular.module('plunker',['ngRoute']); app.config(function ($routeProvider) { $routeProvider.when('/login',templateUrl: 'http://localhost:8888/AngularJs/login.html' }).otherwise({ redirectTo: '/login' }); });
错误代码1: –
XMLHttpRequest无法加载file:// localhost / Users / karthicklove / Documents / Aptana Studio 3 Workspace / Object_Javascript / Angular_Js / Routing / login.html.交叉源请求仅支持协议方案:http,chrome-extension-resource.
错误代码2: – [$sce:insecurl] http://errors.angularjs.org/1.2.26/ $sce / insecurl?p0 = http:// localhost:8888 / AngularJs / login.html出错(本机)
并且还像这样更改模板URL
templateUrl: '/AngularJs/login.html'
如果你有疑问在这里发布.
angularjs – Angular – 我可以从角度应用程序外部广播消息吗?
现在,SDK的处理方式不同:
推特
twttr.events.bind('click',function(event){ // here I'd like to somehow // $rootScope.$broadcast("twitter:clicked",event.currentTarget) });
Facebook的
FB.Event.subscribe("edge.create",function(resp) { // here I'd like to somehow // $rootScope.$broadcast("facebook:clicked",resp) });
一些控制器
app.controller("SomeController",['$scope',function($scope) { $scope.$on("facebook:clicked",function(event,resp) { // do something with resp }); $scope.$on("twitter:clicked",target) { // do something target }); }])
我们的想法是绑定这些事件处理程序,然后处理相关控制器中的广播消息,即使每次获取新内容时都会重新创建这些控制器.
所以基本上,我正在寻找的是一种方法来挂钩现有的已经初始化的角度应用程序的$rootScope和$广播消息,尽管不是应用程序的一部分.希望这是有道理的.谢谢.
解决方法
或者,如果您手动引导应用程序,则可以保留对注入器的引用并获取$rootScope:
var injector = angular.bootstrap(element,["myAppModule",...]); var $rootScope = injector.get("$rootScope");
在任何情况下都不要忘记在外部事件后调用$apply.
angularjs – angular.js chrome Access-Control-Allow-Origin
当我使用Firefox时,它工作正常,但当我去Chrome时我收到了消息:
XMLHttpRequest cannot load http://localhost:8080/VirtualLawyerPj/services/timeoftheday/asjson/tue. Origin http://localhost:8090 is not allowed by Access-Control-Allow-Origin.
这是我的服务代码:
angular.module('myAppServices',['ngResource']). factory('Time',function($resource){ return $resource('http://localhost:port/VirtualLawyerPj/services/timeoftheday/asjson/tue',{port:":8080"},{ query: {method:'GET',params:{},isArray:false} }); });
有人有同样的问题吗?
你是怎么做到这一点的?
谢谢.
今天关于在使用AngularJS的Chrome应用中,我可以直接将ngSrc指令用于内部图像吗?和angular ng指令的讲解已经结束,谢谢您的阅读,如果想了解更多关于angularjs – Angular $digest循环使Chrome 50眨眼、angularjs – Angular Js路由谷歌Chrome问题、angularjs – Angular – 我可以从角度应用程序外部广播消息吗?、angularjs – angular.js chrome Access-Control-Allow-Origin的相关知识,请在本站搜索。
本文标签: