Tag: angularjs

在Angular.js中访问会话值

我无法访问由Angular.js控制器中的node.js设置的会话值。 我正在使用Express框架。 如何解决? 这是我的代码。 app.use(express.cookieParser()); app.use(express.session({ secret: '1234567890QWERTY', cookie: { httpOnly: false } })); //setting the values cookies.set('username',username); req.session.username=username;

从HTTPS获取从Heroku错误

我有一个应用程序写angular度和部署在nodejs heroku。 当我在家用电脑上以开发模式运行它时,一切都很棒,并且不会出现任何错误。 但是,一旦我把它提交给heroku我在控制台上得到以下错误信息: Mixed Content: The page at 'https://yasawebsite.herokuapp.com/#/' was loaded over HTTPS, but requested an insecure script 'http://api.tumblr.com/v2/blog/asayorku.tumblr.com/posts?api_key=[MY SECTRET API-KEY]&callback=angular.callbacks._0'. This request has been blocked; the content must be served over HTTPS. 如何从tumblr调用我的数据有问题吗? 这是我在做什么: $http.jsonp('http://api.tumblr.com/v2/blog/asayorku.tumblr.com/posts?api_key=[MY SECRET API Key]&callback=JSON_CALLBACK') .success(function (data) { // my data analysis process }); 这是我在我的server.js文件中设置的 var express = require('express') , […]

Npm在AngularJS phonecat应用程序中启动问题

我下载了AngularJS phonecat应用程序,并在全球范围内安装了bower,http-server,karma,量angular器。 但是当我移动到代码目录并尝试“npm start”时,它运行“npm install”并显示以下错误: angular-phonecat@0.0.0 prestart / Users / twer / angular-phonecat npm安装 npm WARNlocking错误:EACCES,打开'/Users/twer/.npm/_locks/bower-d21e2b2886728075.lock'npm WARNlocking在错误(本机)npm警告locking/Users/twer/.npm/_locks/bower-d21e2b2886728075。锁失败{[Error:EACCES,打开'/Users/twer/.npm/_locks/bower-d21e2b2886728075.lock'] npm WARN锁errno:-13,npm WARN锁代码:'EACCES',npm WARNlockingpath:' /Users/twer/.npm/_locks/bower-d21e2b2886728075.lock'} npm ERR! 达尔文13.4.0 npm错误! argv“node”“/ usr / local / bin / npm”“install”npm ERR! 节点v0.12.2 npm ERR! npm v2.7.4 npm ERR! 尝试解锁/ Users / twer / angular-phonecat / node_modules / bower,但未lockingnpm WARNlocking错误:EACCES,打开'/Users/twer/.npm/_locks/http-server-0dbc63e1ce281434.lock'npm警告locking错误(本地)npm警告locking/Users/twer/.npm/_locks/http-server-0dbc63e1ce281434.lock失败{[错误:EACCES,打开'/Users/twer/.npm/_locks/http-server- 0dbc63e1ce281434.lock'] npm […]

错误:CSRF令牌缺失,hackathon-starter加上AngularJS

我正在将AngularJS整合到黑客马拉松。 正如我在这里用下面的test.html和test.controller.js所提到的那样完成的 <div> The record: {{record}} </div> <div align="right"> <button class="btn btn-lg btn-primary" ng-click="createRecord()" onclick="window.location.href='/order/shipping'"> <i class=""> Create record</i> </button> </div> test.controller.js (function () { 'use strict'; var injectParams = ['$scope', '$location', '$http']; function TestController($scope, $location, $http) { $scope.record = { interId: 1, sku: '107k', category: 'Useful' }; function createRecord(record) { return $http.post('/order/create', record).then(function (response) […]

REST:返回复杂的嵌套数据与多个调用

我有一个REST API由NodeJS提供给AngularJS前端。 我与users : GET /api/users #Returns all users POST /api/users #Create new user GET /api/users/:id #Return a user PUT /api/users/:id #Edit a user DELTE /api/users/:id #Delete a user 这是一个用户: { login : "admin" email : "admin@admin.com" pass : "hashedpassword" … } 我的用户可以属于groups GET /api/users/:id/groups #Return the groups of a user 他们也可以有constraints或者可以inheritance组的constraints GET /api/users/:id/constraints #Return […]

以angular度js将数据从一个页面传递到另一个页面

如何在angularjs中将数据从一个页面传递到另一个页面? 我听说过使用某些服务,但我不知道如何使用它! 下面给出的是我想要执行的function! 在第1页上: <div class="container" ng-controller="mycontrl"> <label for="singleSelect"> Select Date </label><br> <select nAMe="singleSelect" ng-model="dateSelect"> <option value="2/01/2015">2nd Jan</option> <option value="3/01/2015">3rd Jan</option> </select> <br> Selected date = {{dateSelect}} <br/><br/><br/> <label for="singleSelect"> Select time </label><br> <select nAMe="singleSelect" ng-model="timeSelect"> <option value="9/10">9AM-10AM</option> <option value="10/11">10AM-11AM</option> <option value="11/12">11AM-12PM</option> <option value="12/13">12PM-1PM</option> <option value="13/14">1PM-2PM</option> </select> <button ng-click="check()">Check!</button> <br> Selected Time = {{timeSelect}} <br/><br/> […]

错误:AotPlugin被检测到,但它是一个错误类的实例

问题 服务 模块构build失败:错误:AotPlugin被检测到,但是它是一个错误类的实例。 完整的错误报告日志 ERROR in ./src/main.ts Module build failed: Error: AotPlugin was detected but it was an instance of the wrong class. This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies. at Object.ngcLoader (D:\testingapp\node_modules\@ngtools\webpack\src\loader.js:358:19) @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts npm ls […]

如何使得Angularjs在html5mode上与expressJs路由工作

我已经发布了一个问题( CSS和JavaScript没有包括在刷新上 )昨天问我关于为什么CSS和JavaScript没有包括在我的网页上后,我刷新网页,发现它造成的html5mode,所以自昨天以来,我一直在寻找这个问题的解决scheme,但我不能真正得到答案。 我的文件夹结构 app.js var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path') , mongoose = require('mongoose'); var app = module.exports=express(); // all environments app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/public/views'); app.set('view engine', 'ejs'); app.use(express.cookieParser()); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.static(path.join(__dirname, 'public'))); app.use(app.router); […]

Yeoman,Angular Generator和Karma Test不起作用

我正在试图使用angular发生器的 Yeoman来启动一个新的应用程序。 我运行这个命令(根据文档)开始一个新的应用程序: yo angular my-app-name 所有的依赖已经下载,如果我运行 grunt serve 我的基本应用程序显示在浏览器中,一切看起来工作正常。 当我尝试运行时,问题就开始了: grunt test 我得到一个错误: Warning: Task "karma" not found. Use –force to continue. Warning: Task "karma" not found. Use –force to continue. 所以我添加了这些行: "grunt-karma": "*", "generator-karma": "*" 在我的packeage.json文件中,删除node_modules文件夹并`npm install 。 我正在解决这个问题,但现在我得到的错误: loading "grunt-karma.js" tasks…ERROR >> Error: Cannot find module 'socket.io-client' Warning: Task "karma" not found. […]

结合AngularJS,HTML5位置和超大型

我一直在使用nodejs http-server来为我的Angular应用程序提供服务,但是它不适用于HTML5位置,因为使用它们需要服务器redirect,而http-server不这样做。 所以我看到了一个build议尝试超大型 ,并安装它。 然后我设置了以下superstatic.json文件: { "routes": { "Admin/**":"/index.html", "Give/**":"/index.html", "Pending/**":"/index.html", "Store/**":"/index.html" } } 我用它启动了它 superstatic –config superstatic.json 虽然它正确地提供了我的应用程序,如果我在“/”开始,重新加载index.html文件,但不要做任何文件的angular度处理。 有没有人成功地使用angular质超大型?