草庐IT

has-scope

全部标签

javascript - Angular : Pass $scope variable as directive attribute

我试图将$scope变量值作为属性传递给自定义指令,但它不起作用。这是HTML代码:{{q.question}}指令是,这里是指令代码:app.directive('checkList',function(){return{restrict:'E',template:function(elem,attrs){console.log(attrs.name);return'YesNo'},link:function(scope,elem,attrs){}};})我正在记录属性attrs.name但我得到的值是"{{q.id}}"而不是q.id的实际值 最佳答案

javascript - Angular 力矩 : Moment Timezone has no data for America/New_York

从服务器收到的日期是UTC时区,我需要将其转换为特定时区,例如:America/New_York。以下是相同的代码但是在这样做时我得到了以下错误:MomentTimezonehasnodataforAmerica/New_York.Seehttp://momentjs.com/timezone/docs/#/data-loading/.但是America/New_York是moment的已知时区,但它仍然要求我添加时区。 最佳答案 您需要加载以下所有内容:时刻时刻时区moment-timezone的时区数据Angular矩关于mom

javascript - angular-google-maps TypeError : $scope. map.control.refresh 不是函数

我将angular-google-maps集成到我的cordova移动应用程序中。我想使用以下函数刷新map。functionrefreshMap(){$scope.map.control.refresh({latitude:$scope.location.T_Lat_Deg_W.value,longitude:$scope.location.T_Long_Deg_W.value})}但是出现错误angular.js:13540TypeError:$scope.map.control.refreshisnotafunctionatScope.refreshMap(mapControll

javascript - jQuery 中转 : Object none has no method 'setFromString'

我已经在jQuerytransit中加载了,我确定我是在加载jQuery之后才做的,但我仍然得到这个错误:我查看了Chrome中的资源面板,在jQuery之后加载了jQuerytransit。它也已正确加载,并且没有出现任何问题。我也在控制台测试过,测试网站上的例子。他们都返回同样的错误。这是我的代码:$("#current-employersa.industry-company-link").click(function(e){e.preventDefault();varurl=$(this).attr("href");varcompany_container=$("#current

javascript - 未捕获的类型错误 : Object [object Object] has no method "fancybox"

我对fancybox(2.x)有一个非常奇怪的问题。我使用这个脚本已经很久了,但我以前没有遇到过这样的问题。所以,我有网站:http://tinyurl.com/6mx7an8我已经按照手册中的说明包含了每个jquery/fancybox文件,但是JS控制台给了我错误UncaughtTypeError:Object[objectObject]没有方法'fancybox'你知道我做错了什么吗?任何帮助将不胜感激:) 最佳答案 您的网站有几个问题。您在包含fancybox插件js之前和之后两次包含jQuery库,因为第二次包含jQuer

javascript - typescript : How to resolve 'rxjs/Rx has no exported member ' SubscriptionLike'

我在这里尝试遵循这个例子https://www.youtube.com/watch?v=gxCu5TEmxXE,但是在执行tsc-p时,出现错误。有什么我需要导入的吗?错误:node_modules/@angular/common/src/location/location.d.ts(1,10):错误TS2305:模块'"...functions/node_modules/rxjs/Rx"'没有导出成员'SubscriptionLike'。TS文件import"zone.js/dist/zone-node";import*asfunctionsfrom"firebase-functio

javascript - typescript TS7015 : Element implicitly has an 'any' type because index expression is not of type 'number'

我在Angular2应用程序中遇到此编译错误:TS7015:Elementimplicitlyhasan'any'typebecauseindexexpressionisnotoftype'number'.导致它的代码是:getApplicationCount(state:string){returnthis.applicationsByState[state]?this.applicationsByState[state].length:0;}但这不会导致此错误:getApplicationCount(state:string){returnthis.applicationsBySt

javascript - 变量 : local scope, 全局范围还是 JavaScript 引擎?

这是我在学习JavaScript作用域时发现的一些有趣的东西。代码varfoo="Thisisaglobalvariable.";varbar=function(){alert(foo);foo="Valuehasbeenmodified";}bar();alert(foo);这给出了您认为会得到的正常响应,但如果我更改这一行:来自:foo="Valuehasbeenmodified";到:varfoo="Valuehasbeenmodified";我得到的foo值为undefined,这是为什么?既然函数是全局范围的,为什么它不接受前面的var关键字呢?编辑现在我基本上明白发生了什么

JavaScript 示例问题 : lexical scoping/closure - Eloquent Javascript

所以我是编程新手,我正在尝试通过EloquentJavascript这本书学习JS。到目前为止一切顺利,直到我用下面的代码实现了一个例子functionmakeAddFunction(amount){functionadd(number){returnnumber+amount;}returnadd;}varaddTwo=makeAddFunction(2);varaddFive=makeAddFunction(5);show(addTwo(1)+addFive(1));注意:show类似于alert,只是它在教程集成的JS控制台屏幕上显示变量。作者说这是一个展示词法作用域如何允许合成

javascript - Angularjs "Controller as"或 "$scope"

我想知道angularjs中“Controlleras”或“$scope”语法之间的主要区别是什么。它们对性能有影响吗?如果有,哪种语法更可取。“Controlleras”语法肯定会提高代码的可读性,因为Knockout.js和其他JavaScript框架遵循相同的语法。$scope将提供作用域继承,这有时会给我们带来奇怪的行为,例如ParentController:ChildController:app.controller('ParentController',function($scope){$scope.parent="parentScope";}).controller('C