Tag: angularjs

部署yeoman fullstack到heroku

我试图把我的Yeoman FullStack部署到Heroku。 我正在使用Grunt grunt buildcontrol:heroku来做这件事。 我把主代码推送到Heroku没有错误 remote: Compressing source files… done. remote: Building source: remote: remote: —–> Using set buildpack heroku/nodejs remote: —–> Node.js app detected remote: remote: —–> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NPM_CONFIG_PRODUCTION=true remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: remote: —–> Installing binaries remote: engines.node (package.json): >=0.10.0 remote: engines.npm (package.json): unspecified (use […]

使用mongodbembeddedJson数据

我正在用nodejs使用mongodb。 我刚开始使用mongodb。 我有一个查询。这里是我的mongdb文档: { "_id": ObjectId("564dacf84d52785c1d8b4567"), "content": "This blog created by karanSofat", "html": "<p>This blog created by karanSofat</p>\n", "saved_at": ISODate("2015-11-19T11:05:28.618Z"), "title": "my blog" } 我想和这个数据联系起来。 我希望我的JSON应该在用户评论的时候。 { "_id": ObjectId("564dacf84d52785c1d8b4567"), "comments": [ { "name": "arpit", "email": "arpit@gmail.com", "comment": "How can Make we this at good", "posted_at": ISODate("2015-11-19T11:06:03.628Z") }, { "name": "sumit", "email": "sumit@ggi.net", "comment": "this is […]

将带有图像的angular度file upload请求传递到node.js中的Azure

我几乎有这个工作。 我使用angular-file-upload( http://nervgh.github.io/pages/angular-file-upload/examples/image-preview/ )将file upload到nodejs服务器,然后将其传递给Azure。 router.post('/storeimg', function (req, res, next) { //create write stream for blob var blobSvc = azure.createBlobService(); blobSvc.createContainerIfNotExists('images', function (error, result, response) { if (!error) { // Container exists and allows // anonymous read access to blob // content and metadata within this container var stream = blobSvc.createWriteStreamToBlockBlob( 'images', 'test.png'); //pipe req […]

使用MongoDB设置Angular / Ionic移动应用程序

我想知道有没有人可以帮助我。 我发布了关于这个标题的前一个问题,但是我没有收到太多的回应(可能是由于缺乏信息)。 我从一个Ionic应用程序开始,并使用状态URLS构build视图文件,以在WWW文件夹中从一个页面到另一个页面进行导航。 然后,我为视图文件创build了相应的控制器,用于基本的调用和function,我希望我的应用程序通过Ionic在前端完成。 我的问题是我如何设置MongoDB + Mongoose,所以我可以访问我创build的模型? 我已经search了互联网,但无济于事,我的意思是我知道在这种types的应用程序中没有定义模型的方法,但一些一般的指导将非常感激。 我知道,在使用Angular构build应用程序时,本质上是构build了2个应用程序,即CSS,JS和HTML在前端框架上的前端。 然后运行服务器的后端应用程序存储数据并运行业务逻辑。 这是我为我的应用程序创buildUser Schema模型的地方,并且在运行mongod时通过MongoDB shell将文档插入到我的数据库中。 不过,我还在我的前端的另一个模型文件夹中创build了一个users.js,在这个文件夹中,我通过get,save,query,remove或delete等方法返回一个url后面的资源。 首先,我想说的是,我在构build移动应用程序方面相对比较陌生,所以这可能是完全错误的,其次,在我的应用程序中,我会迷失方向。 我已经尝试在我的app.js文件中设置一个快速服务器,我可以通过我的terminal连接到它,因为它正在监听端口号,但是在浏览器中,它提出了不能/ GET。 如果您需要更多信息,请随时询问,我知道我没有真正了解任何技术,但是我真的不确定,即使我提出了正确的问题。 先谢谢你。

Angular Node JWT令牌authentication和页面redirect

我正在从https://auth0.com/blog/2014/01/07/angularjs-authentication-with-cookies-vs-token/学习JWT令牌authentication。 我试图实现它。 它工作正常。在这里,authentication后控制返回到相同的页面。 我的问题是我们如何可以redirect到客户端控制器的新的HTML页面(限制资源,of course!)? 我曾尝试过一些类似的东西 $scope.submit = function () { $http.post("http://localhost:3000/authenticate?uname=" + $scope.username + "&pwd=" + $scope.password + "") .success(function (data, status, headers, config) { $window.sessionStorage.token = data.token;// Save jwt in the sessionStorage $scope.isAuthenticated = true; var encodedProfile = data.token.split('.')[1]; var profile = JSON.parse(url_base64_decode(encodedProfile)); console.log('encoded profile is ' + profile); window.location.href="api/admin.html"; }) .error(function (data, […]

与angular和节点的Oauth

我有麻烦得到oauthangular度工作。 当我直接进入链接到浏览器 http://localhost:8080/auth/twiter 我能够使用oauth进行连接,并得到回应但是,当我试图用下面的代码angular度做到这一点 login_twitter : function login_twitter(){ var deferred = $q.defer(); $http.get('auth/twitter') .success(function (data,status){ if(status === 200 && data.state=='success'){ user = data.user.name; defered.resolve(); } else{ deferred.reject(); } }) .error(function (data){ deferred.reject(); }); return deferred.promise; 我从浏览器中得到一个错误 XMLHttpRequest cannot load ….link… No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed […]

如何使用客户端模板的护照js?

我正在使用护照js来处理一些身份validation。 不过,我也使用angular度$路线服务来处理我的模板在客户端。 因此,我不确定如何继续使用护照,因为doc页面上的示例假设服务器端模板。 例如, app.post('/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true }) ); 所以基于此,“/”和“/ login”似乎是为模板提供服务,而不仅仅是对REST式查询的响应。 我正在做的事情,我的模板发生在客户端。 在我的angular度文件,设置一切 $routeProvider .when('/', { templateUrl: 'templates/login.html', controller: 'MainCtrl' }) .when('/home', { templateUrl: 'templates/home.html', controller: 'MainCtrl' }); 看来我正在努力混搭,而不是真正理解任何一种做事的方法。 所以我知道我可能已经把这个可怕的措辞说到目前为止,但是我想要做的就是这样的事情 html(login.html) <h3> Login </h3> <form action= "login" method="post"> Username:<br> <input type="text" name="username" value=""> <br> Password:<br> <input type="password" name="password" value=""> […]

Angularjs与html5Mode的正常链接

我正在使用html5模式的angularjs。 这似乎控制了页面上的所有href。 但是,如果我想在应用程序的同一个域中有一个链接,但实际上并不在应用程序中。 一个例子就是pdf。 如果我做<a href="/pdfurl">angular将尝试使用html5mode并使用路线提供程序来确定应该加载哪个视图。 但我实际上希望浏览器以正常的方式进入该页面。 要做到这一点的唯一方法是与路线提供商制定一个规则,并redirect到正确的页面与window.location?

aws s3file upload使用aws-sdk nodejs

我试图从用户{angularjs前端}上传文件到aws s3桶,并parsing文件到nodejs api路由,但不断收到错误:“TypeError:无法读取未定义的属性”文件“..我能够从postman(铬扩展)上传文件通过发送文件的请求,但我不知道如何parsing文件从angular度到节点js。 下面是在做什么: // NODEJS代码: router.post('/user/upload', multipartMiddleware, function(req, res){ var file = req.files.file; var body = fs.createReadStream(file.path); var filename = 'post7/media.jpg'; var s3bucket3 = new AWS.S3(); s3bucket3.createBucket({Bucket: 'artistarc-user-post-media'}, function() { var data = {Bucket: 'artistarc-user-post-media', Key: filename, Body: body}; s3bucket3.putObject(data, function(err, data) { if (err) { console.log("Error uploading data: ", err); } else { […]

使用Moment.js和Angular的时间

我正在使用Angular与angular-moment软件包。 使用am-time-ago指令 <span am-time-ago="message.time"></span> 给出了5 hours ago , a day ago , 15 days ago 。 Questoin :我们怎样才能把它格式化成自定义格式5d , 1d , 15d ?