你好,我是angularJS的新手,并试图阻止访问基于用户标识的某些状态。 这从ui路由器的FAQ描述了我想要做什么,但是我不能让它正常工作。 我需要什么,但在数据对象完全是为了完成这个? (我看到有人在一些博客文章中引用了“真实”,并像我一样使用它,但似乎没有工作,因为我得到一个错误,说明needAdmin没有定义) 这是我的代码: angular.module('courses').config(['$stateProvider', function($stateProvider) { // Courses state routing $stateProvider. state('listCourses', { url: '/courses', templateUrl: 'modules/courses/views/list-courses.client.view.html' }). state('createCourse', { url: '/courses/create', templateUrl: 'modules/courses/views/create-course.client.view.html', data: { needAdmin: true } }). state('viewCourse', { url: '/courses/:courseId', templateUrl: 'modules/courses/views/view-course.client.view.html' }). state('editCourse', { url: '/courses/:courseId/edit', templateUrl: 'modules/courses/views/edit-course.client.view.html', data: { needAdmin: true } }); } ]); angular.module('courses').run(['$rootScope', '$state', […]
( <a href="…"> )提交单击时embedded的表单的最佳方式是什么? <form> <ul> <li> <p> The link could be <span>embedded <a href="" onclick="?">at any level</a></span> in the form, so "this.parentNode.parentNode…" is no good. 🙁 </p> </li> </ul> </form> 我知道使用jQuery的最简单的方法是 $('#myLink').click(function() { $(this).parents('form:first').submit(); }); …但我试图find一种方法来做到这一点,而不使用图书馆。 编辑 :我真的想find一种方法,不需要知道的forms(例如:其名称,ID等)。 这与您可以将其放在input元素上的方式类似: <input onclick="this.form.submit()" />
在一个简单的setInterval setInterval(function() { // Do something every 9 seconds }, 9000); 第一个动作将在9秒后发生( t=9s )。 如何强制循环立即执行第一个动作( t=0 )? 我认为这是由于setInterval的机制有Delay – Action – Delay – Action …循环; 而不是Action – Delay – Action – Delay …循环。 编辑:我的function确实是一个循环 setInterval(function(){ $('.test').each(function(idx){ var duration = 1000; $(this).delay(duration*idx); Some stuff here }); }, 4000);
我需要将json对象转换为urlforms,如:“parameter = 12&asd = 1” 我完成了这个: var data = { 'action':'actualiza_resultado', 'postID': 1, 'gl': 2, 'gl2' : 3 }; var string_=JSON.stringify(data); string_=string_.replace(/{/g, ""); string_=string_.replace(/}/g, ""); string_=string_.replace(/:/g, "=") string_=string_.replace(/,/g, "&"); string_=string_.replace(/"/g, ""); 但我不知道是否有任何在JavaScript或JSON对象的function做到这一点?
我很确定答案是否定的 ,因此谷歌齿轮,Adobe AIR等 如果我是对的,那么http://tiddlywiki.com如何工作? 它是持久的,用JavaScript编写的。 它也只是一个没有外部(serverside)依赖关系的HTML文件。 WTF? 在哪里/如何存储其状态?
我正在使用jQueryvalidation来validation表单。 我的表单上有两个文本框,只有第一个将添加“此字段是必需的”。 信息。 如果我从第一个中删除“required”类,第二个将会有消息。 HTML: <form id="questionForm"> <div><input class="required" id="value" type="text" /></div> <div><textarea class="required" id="description"></textarea></div> <button type="submit">Save</button> </form> JavaScript的: $("#questionForm").validate({ submitHandler: function() { alert("valid"); } }); 为什么只有一个被validation? 编辑:我正在使用jQueryvalidation插件1.7 http://bassistance.de/jquery-plugins/jquery-plugin-validation/ http://docs.jquery.com/Plugins/Validation 编辑2:我正在使用MVC 3
我试图实现一个file uploadAPI,在这里给出: Mediafirefile upload 我成功地能够上载Post数据和获取数据 ,但是不知道如何发送x-filename属性,这个属性是API指南中给出的Header数据 。 我的代码: xmlhttp=new XMLHttpRequest(); var formData = new FormData(); formData.append("Filedata", document.getElementById("myFile").files[0]); var photoId = getCookie("user"); // formData.append("x-filename", photoId); //tried this but doesn't work // xmlhttp.setRequestHeader("x-filename", photoId); //tried this too (gives error) [edited after diodeous' answer] xmlhttp.onreadystatechange=function() { alert("xhr status : "+xmlhttp.readyState); } var url = "http://www.mediafire.com/api/upload/upload.php?"+"session_token="+getCookie("mSession")+"&action_on_duplicate=keep"; xmlhttp.open("POST", url); // […]
我刚刚在我的Ubuntu 14.04操作系统上首次安装了Node.js 我也安装了npm 。 我的安装过程中的下一步是安装nodemon 。 这一切都很好。 但是,当我通过在我的命令行中键入nodemon app.js来运行nodemon时,出现以下错误… [nodemon] 1.8.1 [nodemon] to restart at any time, enter rs [nodemon] watching: *.* [nodemon] starting节点app.js [nodemon] Internal watch failed: watch ENOSPC 在错误下面的命令行中… alopex@Alopex:~/Desktop/coding_dojo/week-9/javascript/node/testing_node$ Hello World 为什么发生这种情况? 这是nodemon的正常行为? 如果没有,我该如何解决? 边注… 1) app.js是一个包含console.log(111)的Javascript文件。 2) node版本是v0.10.25 3) npm版本是1.3.10 4) nodemon版本是1.8.1 5) ubuntu版本是… Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS […]
我想在下一个项目中使用node.js,但是我的老板不喜欢我们的竞争对手可以读取源代码。 有没有一种方法来保护JavaScript代码?
可能重复: 返回到上一页 回到上一页 如何获得JavaScript编码的前一页。 单击后退button时转到上一页。