草庐IT

has-scope

全部标签

javascript - JQuery 错误 : Uncaught TypeError: Object #<HTMLDocument> has no method 'ready'

我的站点在javascript控制台中出现此标题错误。谷歌好像说是因为jquery没有加载,但是在head里面肯定是看得见的。$(document).ready(function(){$.ajax({type:"GET",url:"https://www.mjfreeway.com/naturalremedies/mml-connect/45.xml",dataType:"xml",success:function(xml){$(xml).find("products").each(function(){$(this).find("product").each(function(){$

javascript - 如何在 Angular 1.5 组件中等待绑定(bind)(没有 $scope.$watch)

我正在编写一个Angular1.5指令,我遇到了一个令人讨厌的问题,试图在绑定(bind)数据存在之前对其进行操作。这是我的代码:app.component('formSelector',{bindings:{forms:'='},controller:function(FormSvc){varctrl=thisthis.favorites=[]FormSvc.GetFavorites().then(function(results){ctrl.favorites=resultsfor(vari=0;i如您所见,我正在调用AJAX来获取收藏夹,然后根据绑定(bind)的表单列表检查它。

javascript - TypeError : $scope. 应用不是函数

我试图在通过rdflib.js检索后呈现联系人列表。它正在正确加载并将其保存在范围内的列表中。但由于$scope没有更新,我无法渲染,似乎我在错误的地方调用了$scope.apply()。发生错误是因为我在Angular之外调用它,但我故意在Angular上下文(nowOrWhenFetched)之外的函数内调用它,所以对我来说没有意义。有帮助吗?$scope.load=function(){//$scope.getContactsList();varg=$rdf.graph();varf=$rdf.fetcher(g);f.nowOrWhenFetched($scope.path+'

javascript - AJAX 请求后未调用指令中的 scope.$watch

我有以下指令:MyApp.directive('myFilter',['$filter','$rootScope',function($filter,$rootScope){vardir={};dir.restrict='E';dir.templateUrl='views/myFilter.html';dir.replace=true;dir.scope={name:'@',model:'=',};dir.link=function(scope,el,attrs){//stuffhere}returndir;}]);下面是我如何调用它:当指令第一次初始化时,someField是空的。之

javascript - AngularJS 中的 $scope 是什么?

关闭。这个问题需要更多focused.它目前不接受答案。想改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭8年前。Improvethisquestion我是AngularJS的新手,我不明白AngularJS中的$scope是什么。有人可以用最简单的方式解释AngularJS中$scope的作用以及我们可以用它做什么吗?请以一种完全不懂编程的人的方式来解释它。也有人可以用最简单的方式逐行解释下面的代码吗?functionMyController($scope){$scope.username='World';$scope.sayHello=functio

javascript - Angular : How to access scope from ui-grid cell template?

如何从ui-grid单元格模板访问$scope?这是我的Controller代码:app.controller('MainCtrl',['$scope',function($scope){//iwanttoreferencethisfromacelltemplate.$scope.world=function(){return'world';};$scope.gridOptions={data:[{id:"item1"},{id:"item2"}],columnDefs:[{field:'id',//world()isnevercalledandisnotdisplayed.cellT

javascript - $scope.$root 和 $rootScope 有什么区别?

我在Controller中看到$scope有$root,这是什么?它与可以在Controller中注入(inject)的$rootScope有何不同? 最佳答案 $rootScopevar指向所有范围的父级并且可以在任何地方注入(inject)。所有其他范围都是$rootScope的子级。它们是通过$rootScope的$new方法创建的,因此每个作用域都继承自$rootScope。在Scope构造函数定义中的Angular源中thereisaline:functionScope(){this.$id=nextUid();...th

javascript - JavaScript(或 jQuery)中是否有 'has focus'?

有什么我可以这样做的吗(也许通过插件)if(!$('form#contactinput]').hasFocus()){$('form#contactinput:first]').focus();}基本上,将焦点设置到第一个输入,但前提是用户尚未点击任何内容?我知道这也行,但还有更优雅的吗?$(function(){varfocused=false;$('form#contactinput]').focus(function(){focused=true;});setTimeout(function(){if(!focused){$('form#contactinput:first]')

javascript - Angularjs 指令 : Isolated scope and attrs

请看例子herefoodMeApp.directive('fmRating',function(){return{restrict:'E',scope:{symbol:'@',max:'@',readonly:'@'},require:'ngModel',link:function(scope,element,attrs,ngModel){attrs.max=scope.max=parseInt(scope.max||5,10);...Angular需求symbol,max,readonly在隔离作用域对象中定义,以便从父作用域访问它。它被使用here那么,attrs的目的是什么??不

javascript - Bootstrap : 'TypeError undefined is not a function' /'has no method ' tab'' when using bootstrap-tabs

我目前正在构建一个小网站,想使用Initialzr中的一些Bootstrap部件,特别是选项卡。我目前尝试使用Bootstrap项目(http://twitter.github.com/bootstrap/javascript.html#tabs)提供的示例代码和一些调整,但在加载时得到“未定义不是函数”。JS文件以正确的顺序预加载(jQuery、libs/bootstrap/*、我的script.js文件/混合在html中的脚本),标准jQuery命令(隐藏等)都可以正常工作,所以它不会似乎与noConflict()选项有关。我还需要检查什么? 最佳答案