草庐IT

in-function

全部标签

javascript - Angular 2/4 : How to restrict access to Login Route if user is already logged in?

我有以下路线定义。exportconstRoutes=RouterModule.forChild([{path:'login',component:LoginComponent},{path:'protected',canActivate:[AuthGuardService],component:ProtectedComponent},{path:'home',component:HomeComponent,canActivate:[AuthGuardService],},]);我已成功实现AuthGuardService,如果用户未登录,它会限制对protected路由的访问。我想要

javascript - 猫头鹰旋转木马 : Run function when last slide is reached

我正在尝试在到达轮播的最后一张幻灯片时运行一个函数。我已经设法使用afterInit和afterMove回调来循环轮播项目,但我只需要能够在循环结束时运行一个函数。希望你能帮到你。插件:http://owlgraphic.com/owlcarousel/#customizingslideshow.owlCarousel({navigation:false,//ShownextandprevbuttonsslideSpeed:300,paginationSpeed:400,singleItem:true,autoPlay:false,stopOnHover:false,afterInit

javascript - Angular .js : directive object in scope is always undefined

编辑:fork了@EliteOctagon的plunker,奇怪的是它在工作!无法理解为什么下面的代码不是。http://plnkr.co/edit/y8uvulA9RHQ1Y9mwzin1EDIT2:fork了之前的plunker并向Controller的逻辑添加了$timeout,它停止工作了!猜猜这真的是加载顺序。查看:http://plnkr.co/edit/ivmGQmEHTatNzBWhppyf我是Angular的新手,无法理解指令隔离范围。我需要创建一个指令来打印出在我的页面中,包含关于ViewController中的对象的信息。我试图做的是隔离指令范围并通过具有双向绑定

javascript - Angular : Variables in ng-model

我有一个循环ng-repeatName:{{data.name}}我希望$scope.age变成$scope.age_data.name。例如:$scope.age_Tan、$scope.age_Jim...所以我尝试了ng-model="age_{{data.name}}"但它出错了。如何解决? 最佳答案 执行此操作的“正确”方法是在Controller中执行此操作:$scope.ages={};然后在模板中:Name:{{data.name}}应该工作... 关于javascript

javascript - '错误 : Uncaught (in promise): No provider for Jsonp' (HTML/Javascript/Typescript/Angular2)

错误截图:.ts文件代码(SearchDisplay.component.ts):import{Component,OnInit}from'angular2/core';import{Router}from'angular2/router';import{Hero}from'./hero';import{HeroService}from'./hero.service';import{RouteConfig,ROUTER_DIRECTIVES}from'angular2/router';import{HeroesComponent}from'./heroes.component';imp

javascript - 在 javascript 中创建 "new function"别名的最短方法

创建“新函数”别名的最短方式(字符)是什么。基本上这是为了代码高尔夫和超出合理范围的缩小代码。所以当你通常会写:a=function(a,b,c){returna+b+c;}你可以这样写(也让我们用全局变量R抽象return关键字):a=$("a,b,c","R=a+b+c")a=$(a,b,c){R=a+b+c}(不确定第二个是否可行。)对于第一个例子,我想到的最好的是:$=function(a,b){returnnewFunction(a,"R=0;"+b+";returnR")}大小(用法、声明)都很重要,但使用大小更重要。 最佳答案

javascript - Uncaught ReferenceError : function is not defined jQuery

我试图在单击按钮时调用jQuery函数。但是我收到如下错误:未捕获的ReferenceError:未定义update_question_ajaxHTML:button"onclick="update_question_ajax()"style="outline:0none;">jQuery:$(function(){functionupdate_question_ajax(id){vartest=$('.edit-question-'+id+'input[name="translated"]');vareditedQuestionId=$('#question-id-'+id).val

javascript - 尝试使用 React Hooks 时出现 "TypeError: Object(...) is not a function"错误(alpha)

这个问题在这里已经有了答案:HowtousenewFeatureHooksinReact?(1个回答)关闭4年前。当我尝试使用新的Reacthooks功能时,出于某种原因我遇到了这个烦人的错误消息。我按照文档中的说明使用yarnaddreact@next将React升级到最新的alpha版本。

javascript - Angular : update $scope doesn't work in setTimeout callback

在angular.js中,$scope.greeting=xxx在window.setTimeout中不起作用。它没有任何效果:varmyApp=angular.module('myApp',[]);myApp.controller('MyCtrl',function($scope){$scope.greeting='init';window.setTimeout(function(){console.log('updategreeting');$scope.greeting="hello";//doesn'tworkhere.},3000);})为什么?完整对比如下:有效(在ajax

javascript - 类型错误 : Converting circular structure to JSON in nodejs

我正在使用node.js的请求包代码:varformData=({first_name:firstname,last_name:lastname,user_name:username,email:email,password:password});request.post({url:'http://localhost:8081/register',JSON:formData},function(err,connection,body){exports.Register=function(req,res){res.header("Access-Control-Allow-Origin",