我有一个自定义事件 core-transitionend
(实际上由 Polymer 触发),我可以使用 document.addEventListener()
设置事件处理程序.但在 AngularJS 中执行此操作的最佳做法是什么?
或者,我可以在 DOM 中明确设置一个处理程序,即 <paper-ripple on-core-transitionend="enter()"></paper-ripple>
, 但是如何在 AngularJS 中定义这个函数呢?
最佳答案
参见 this fiddle ,我在这里创建了一个自定义指令,它将事件绑定(bind)到元素,
angular.module('HelloApp', [])
.directive('customDir', function () {
return {
restrict: 'A',
link: function(scope, element, attrs)
{
element.bind("click",function()
{
alert("you clicked me");
})
}
}
})
在您的情况下,您可以简单地将定义的事件绑定(bind)到元素
关于javascript - 如何在 AngularJS 中绑定(bind)自定义事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27547156/
我有一个包含这些url的数组:["path/to/url1","path/to/url2","path/url/unicóde.txt"]我正在使用angular,通过ng-repeat我创建了一个可点击的列表,该列表执行重定向到所需的url,但是,当我点击unicodeurl时,浏览器无法找到它。我尝试使用encodeURI("path/url/unicóde"),但它检索到的是:path/url/unic%C3%B3de.txt未找到。相反,当我手动访问时:path/url/unicóde.txt(这是在ftp中,因此,我逐个文件夹直到到达文件)浏览器中的url现在说:path/u
我正在使用WebRTC编写我的第一个点对点连接应用程序,我通过socket.io连接发送的用于从对等点请求icecandidate的代码触发了6次而不是一次。这真的很令人困惑,因为如果我错误地设计了一个大请求循环,我会期望无限递归,而不仅仅是6(8个onicecandidate事件)。那么谁能告诉我为什么下面的代码会产生6个递归?这里是消息处理程序,它只是发送一条由语法控制的socket.io消息:Muveoo.Messenger.input('icecandidaterequest',data);'icecandidaterequest':function(data){console
我正在尝试构建一个带有服务器组件的Electron应用程序,使用express进行远程控制。express模块初始化为varstaticPath=path.resolve('app/assets')setupNotifications(server);app.use(cors());app.use('/api/',json());app.use('/api/',router);app.use('/assets',express.static(staticPath));console.log('servingstaticfilesfrom:'+staticPath);Elecrondoc
我有以下设置并且我的错误/堆栈跟踪有问题我是否遗漏了什么?package.json看起来像:{"name":"xxxxxx","main":"server.js","private":true,"scripts":{"start":"nodemon--exec./node_modules/.bin/babel-nodeserver.js"},"dependencies":{"babel":"^6.5.2","babel-cli":"^6.6.5","babel-preset-es2015":"^6.6.0","babel-preset-react":"^6.5.0","babel-pr
ECMAScript规范定义了UseStrictDirective,但允许实现定义自己的指令。来自here:ImplementationsmaydefineimplementationspecificmeaningsforExpressionStatementproductionswhicharenotaUseStrictDirectiveandwhichoccurinaDirectivePrologue.什么是已知的特定于实现的指令?在Google上快速搜索一下,除了usestrict什么也没有。我能想到useasm和usestrong.还有其他的在用吗?
基于mozilla开发者网络https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine它说Returnstheonlinestatusofthebrowser.Thepropertyreturnsabooleanvalue,withtruemeaningonlineandfalsemeaningoffline.Thepropertysendsupdateswheneverthebrowser'sabilitytoconnecttothenetworkchanges.Theupdateoccurswhen
我尝试使用nodemailer和电子邮件模板发送电子邮件。现在我从这里exampleemailtemplates得到了例子。但是当我检查这段代码时,出现错误apromisewasrejectedwithanon-error:[objectUndefined]请帮帮我。这是我的代码varnodemailer=require('nodemailer');varEmailTemplate=require('email-templates').EmailTemplate;exports.sendOne=function(){vartemplatesDir=config.templatesDir
我的站点中有一个注册表单,我正在其中保存字段,并且在用户再次返回该注册表单时保存表单后,我希望将以前的字段值保存在浏览器自动填充中。下面是我的代码片段-SignUp在anchor标记的onClick代码中,我通过注册用户函数进行ajax调用。之后,我希望用户数据自动填充到chrome中的浏览器自动填充地址中。我尝试了以下方法:-1.很少有人建议使用表单“提交”按钮功能将数据保存在自动填充中,而不是使用ajax调用表单anchor标记的onClick事件。但这对我来说也不起作用。2.我看过一些帖子,其中他们告诉我要为字段使用专有名称和自动完成属性。但使用该浏览器只能猜测正确的字段值。
我在react-redux上有一个客户端应用程序,在loopback上有一个API应用程序。对于本地测试,我在端口8080上运行客户端应用程序,在端口3000上运行服务器应用程序。当我尝试使用客户端应用测试GoogleOAuth(使用loopback-passport组件)时,出现以下错误。当我使用POSTMAN对其进行测试时,没有任何问题。这是客户端代码,require('babel-polyfill');import{CALL_API}from'redux-api-middleware';importCfrom'../constants';constAPI_ROOT='http:/
我正在尝试在我的应用程序中设置代码拆分/分块-通过路由,使用require.ensure。所以这是我的路线:{require.ensure([],(require)=>{cb(null,require('attendee/containers/Profile/').default)},'attendee')}}/>以下是我的webpack配置中的相关行:constPATHS={app:path.join(__dirname,'../src'),build:path.join(__dirname,'../dist'),};constcommon={entry:[PATHS.app,],o