草庐IT

property-injection

全部标签

javascript - 类型错误 : Attempted to assign to readonly property

我在为指令编写测试时遇到了这个错误(使用generator-angular-module):src/capitalize.js:'usestrict';angular.module('jviotti.string',[]).filter('capitalize',function(){returnfunction(input){returninput.replace(/\w\S*/g,function(txt){returntxt.charAt(0).toUpperCase()+txt.substr(1).toLowerCase();});};});测试/规范/capitalize.j

javascript - 未捕获的类型错误 : Cannot read property 'length' of undefined

当我尝试从AJAX调用中获取数据并在单击提交按钮时将其插入另一个函数时,如何避免出现以下错误?ajax函数中的console.log调用显示数据已被抓取,我希望然后存储在json_data中。当时的目的是使用此数据来更改通过HTML表单提交的字符串。然后在“点击”函数的行返回错误:console.log(json_data.length);TestForm#results_box{border:red5pxsolid;}#place{border:#cccccc1pxsolid;}$(document).ready(function(){varjson_source="https://

javascript - Angularjs 自定义过滤器和依赖注入(inject)

我是AngularJS的新手,我经常看到这种语法:functionsomeFunc(){returnfunction(input){return'hello'+input;}}上面的函数是我经常看到的一般语法,但这个自定义过滤器示例的问题是特定的:angular.module('bookFilters',[]).filter('newBookFilter',function(){returnfunction(input){return'TheBook:'+input.name+'isnew!';};});我知道用另一个函数包装函数让我有机会使用依赖注入(inject),这是我的问题:过

javascript - IE 11 浏览器错误 - 异常 : Object doesn't support property or method 'matches' , 其他浏览器工作正常

就我而言,该网页在firefox和chrome浏览器中运行良好,但在IEv.11中它显示错误为errorcomesinIE11DEVELOPERTOOLS.该错误显示在IE11的开发人员工具中。该错误不允许打开特定链接,单击它会显示以下错误。polyfills.ts-*BROWSERPOLYFILLS*//**IE9,IE10andIE11requiresallofthefollowingpolyfills.**/import'core-js/es6/symbol';import'core-js/es6/object';import'core-js/es6/function';impo

javascript - 错误 :InvalidValueError: setCenter: not a LatLng or LatLngLiteral: in property lat: not a number

functioninitAutocomplete(){varlat=document.getElementById('lat').value;varlng=document.getElementById('lng').value;console.log(lat);console.log(lng);varmap=newgoogle.maps.Map(document.getElementById('map'),{center:{lat:lat,lng:lng},zoom:13,mapTypeId:'roadmap'});}它给了我以下错误:error:InvalidValueError:

javascript - 自定义过滤器在 AngularJS 中给出 "Cannot read property ' 切片' of undefined"

我的自定义startFrom过滤器给我一个错误。app.filter('startFrom',function(){returnfunction(input,start){start=+start;//parsetointreturninput.slice(start);}});app.controller("PostCtrl",function($scope,$http){$scope.currentPage=0;$scope.pageSize=10;$scope.hidePagination=true;$scope.search=function(){$http.get('some

javascript - AngularJS 动态注入(inject)范围或 Controller

是否可以在运行期间注入(inject)作用域或Controller?或任何其他将服务动态注入(inject)Controller的建议?Application.controller('IndexController',function($scope){//someactionsif(someconditions){$scope.$inject=[someServiceName];//andhereiwanttouseservicemethods}});提前致谢 最佳答案 可以使用$injector将服务动态注入(inject)(按名

javascript - 未捕获的类型错误 : Cannot read property 'getElementsByTagName' of null

我正在尝试使用.getElementsByTagName()选择元素。vartags=document.body.getElementsByTagName("*");当前尝试使用从现有答案中吸取的教训https://stackoverflow.com/questions/7410949/javascript-document-getelementsbyclassname-compatibility-with-ie/7410966#7410966但是我的尝试失败了,出现了这个错误:UncaughtTypeError:Cannotreadproperty'getElementsByTagN

javascript - YouTube(注入(inject))视频结束回调

我将YouTubeiframe注入(inject)文档准备好的div并将其绑定(bind)到点击:jQuery(document).ready(function($){jQuery('.video-thumb').click(function(){...$('#player').html('');...}}我想在视频结束时进行回调。我读过onYouTubePlayerAPIReady,但必须准备好外部文件。我已经尝试通过这种外部文件准备加载视频播放器:varplayer;functiononYouTubePlayerAPIReady(){player=newYT.Player('pla

javascript - 类型错误 : Cannot create property 'validator' on string 'abc@gmail.com' at setUpControl

我在formGroup中遇到问题。首先,我根据URL取一些值并调用API来检索前字段文本的特定用户数据。注册.htmlUsername注册.component.tsimport{Component}from'@angular/core';import{FormGroup,AbstractControl,FormBuilder,Validators}from'@angular/forms';import{Router,ActivatedRoute}from'@angular/router';import{EmailValidator,EqualPasswordsValidator}fro