草庐IT

direct_to_template

全部标签

javascript - Angular Directive(指令)内存泄漏?

我正在使用这个简单的html文件重现我发现的内存泄漏:varapp=angular.module('testApp',[]);app.directive('directive1',function(){return{template:'',scope:true};});app.directive('directive2',function(){functionLeakObject(){}functionFoo(){this.bar=function($scope){$scope.nottheredude;};}return{scope:true,link:function($scope

javascript - AngularJS + Django : URL refresh or direct access not loading correctly

我们将AngularJS嵌入到我们的Django应用程序中,并通过AngularJS处理URL路由ui-router.使用ui-sref在各部分之间导航并在应用程序内四处点击,一切正常。return$stateProvider.state('root.dashboard',{abstract:true,url:'dashboard/'}).state('root.dashboard.profile',{url:'profile/',views:{'@':{templateUrl:Urls['dashboard:profile'](),controller:'ProfileControl

javascript - 在 Angular Directive(指令)中从父级继承的新范围

假设我这样做:sAngular.app.directive('dostuff',['$compile',function($compile){return{restrict:'C',scope:{someVar:'='},link:function(scope,element,attrs){element.click(function(){//dostuffscope.someVar='somethingelse';vardropdownOutput=template();varcompiledOutput=$compile(dropdownOutput)(scope);scope.$

javascript - react /归约形式 : how to return promise from onSubmit?

我正在努力思考redux,react-redux和redux-form.我已经设置了一个商店并从redux-form添加了reducer。我的表单组件如下所示:登录表单importReact,{Component,PropTypes}from'react'import{reduxForm}from'redux-form'import{login}from'../../actions/authActions'constfields=['username','password'];classLoginFormextendsComponent{onSubmit(formData,dispat

javascript - React+Redux - Uncaught Error : Expected the reducer to be a function

我尝试了简单的react、redux、ajax工作示例并遵循了RedditAPItutorial,但我无法创建商店并收到错误消息:UncaughtError:Expectedthereducertobeafunction.index.jsx...import{createStore,applyMiddleware}from'redux'varthunkMiddleware=require('redux-thunk');varcreateLogger=require('redux-logger');varrootReducer=require('./reducers.js');const

javascript - ReactJS + 终极版 : How to structure action creators down to each component?

我有一个名为App.js的父组件:...render(){return({React.cloneElement(this.props.children,this.props})}...functionmapDispatchToProps(dispatch){return(actions:bindActionCreators(actions,)}exportdefaultconnect(...,mapDispatchToProps)(App)并且Prop将传递给每个组件。我想让每个组件都有它的actioncreators文件,但是我怎样才能将所有actioncreators绑定(bind

javascript - Ajax 请求 : Refused to set unsafe header

我正在尝试使用GoogleText-To-Speech播放音频。因此,我需要使用正确设置的Referer和User-Agent向他们的端点发送请求。此调用应返回我可以播放的MP3。但是,我得到了Refusedtosetunsafeheader错误。这是我的代码。我该怎么做?$.ajax({url:'http://translate.google.com/translate_tts?ie=UTF-8&q=Hello&tl=en&client=t',beforeSend:function(xhr){xhr.setRequestHeader("Referer","http://transla

javascript - 如何删除标准 iframe Facebook Like 按钮的 "Be the first of your friends to like this"部分?

我使用的是标准的FacebookLike按钮(iframe,而不是fbml)。有没有办法只显示点赞按钮,而不显示“成为你的friend中第一个点赞这个”部分? 最佳答案 目前无法配置。如果您使用button_count布局,那么您将看不到该文本。 关于javascript-如何删除标准iframeFacebookLike按钮的"Bethefirstofyourfriendstolikethis"部分?,我们在StackOverflow上找到一个类似的问题: h

Javascript : Best way to declare functions to be used globally?

我的javascript文件变得非常大(3000多行),我对如何布局我的文件和删除函数以便它们可以在文件中的任何位置调用感到困惑。总结一下我的JS文件现在看起来有点像这样://ALLGLOBALVARIABLESFIRSTDECLAREDHEREvarvar1,var2,var3$(document).ready(function(){//JQUERYSTUFF});//ALLFUNCTIONSTHATNEEDTOBEGLOBALDECLAREDHEREfunctionmyFunction(){//dosomestuffhere}我在这方面遇到了问题,因为我在某些地方调用的函数似乎在调

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