Tag: angularjs

angular js ng-view返回blanc partials – Express / Jade

我正在编写一个angular度的应用程序下面的教程。 令我惊讶的是,我完全按照我的节点js开始没有问题。 但是,我的angular没有返回模板,假设。 我在这里看到类似的问题相同的教程和相同的问题。 但是,这个问题没有回答。 以下是我的dir结构 app.js var app = angular.module('app', ['ngResource', 'ngRoute']); angular.module('app').config(function($routeProvider, $locationProvider){ $locationProvider.html5Mode(true); $routeProvider .when('/', { templateUrl: 'partials/main', controller: 'mainCtrl'}); }); angular.module('app').controller('mainCtrl', function($scope){ $scope.myVar = "Hello Angular"; }); 我的layout.jade doctype html head link(rel="styleSheet",href="css/bootstrap.css") link(rel="styleSheet",href="vendor/toastr/toastr.css") link(rel="styleSheet",href="css/site.css") body(ng-app='app') block main-content include scripts 我的main.jade h1 This is a partial h2 {{ myVar }} 我的server.js路由设置为 app.get('partials/:partialPath',function(req,res){ […]

无法使用MEAN堆栈显示图像

我正在使用MEAN堆栈,并试图显示存储在我的Mongo数据库中的图像。 我相信图像被正确存储并正确传递到浏览器,因为当我使用Web控制台,并看看我的post响应身体显示图像的响应。 我有一个表,当一个单击行时,它会打电话给我的控制器: $scope.detailRequest = function(index){ $scope.selectedRow = index; $scope.selected = this.contact; $http.post('/DetailRequest', $scope.selected).success(function(response){ $scope.detailResponse = response; }); }; 在节点我查询Mongo并返回图像: router.post('/DetailRequest', function(request, response) { reports .findOne({_id : request.body._id}) .select('img') .exec(function (err, research) { response.contentType(research.img.contentType); response.send(research); }); }); 我正在使用ng-src进行图像显示。 正如我在页面顶部提到的,我可以在Web控制台的Response Body中正确地看到图像。 因此,我有信心将图像传回浏览器。 <img ng-src="{{detailResponse}}"> 图像不会显示

如何在单个http请求中检索gridF中的所有图像

我是新的mean.js(angular.js + node.js)和使用GridFs来存储图像。 为了检索图像,现在我发送每个图像的http请求。 我担心这是否会影响网站的速度。 所以我想从gridFs一起检索所有的图像。 那可能吗? 有谁能够帮助我? 下面提供的是我的客户端代码。 $http.get('/uploads?filename=' + imagename).success(function(response) { $scope.img.push({imageph: response, image: item.image, url: item.url}); }).error(function (err) { console.log('Error uploading file: ' + err); }); 我的服务器端代码是: var qo = url.parse(req.url, true).query; var filename = qo.filename; if (filename !== 'undefined') { var rstream = gfs.createReadStream(filename); var bufs = []; rstream.on('data', function (chunk) […]

咕噜生成和服务相对path不匹配

我有一个典型的目录结构设置我的angular应用程序。 我在应用程序目录中也有一个git子模块: app submod submod.js submod.css bower_components dist node_modules bower.json Gruntfile.js package.json … 我的index.html是为grunt build任务设置的。 一切工作正常,除了子模块文件,因为path导致问题。 如果我把“应用程序”放在path中,构build会正常工作: <!– build:css(.) styles/vendor.css –> <!– bower:css –> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" /> <!– … –> <!– endbower –> <link rel="stylesheet" href="app/submod/submod.css" /> <!– endbuild –> 但是,使用grunt serve在本地运行应用程序将不起作用,除非我从path中删除应用程序: <!– build:css(.) styles/vendor.css –> <!– bower:css –> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" /> <!– […]

用户成功login时的Angular.js路由?

我正在关注这个posthttps://medium.com/opinionated-angularjs/techniques-for-authentication-in-angularjs-applications-7bbf0346acec 我已经成功地向服务器发出了一个POST请求,并且我得到了返回的用户对象。下面的服务是什么使请求。 我不明白我在哪里可以路由到仪表板。 /** * Authentication service via medium post Service * */ .factory('AuthService', function ($http, Session, ApiEndpoint) { var authService = {}; authService.login = function (credentials) { console.log(credentials) return $http .post('/api/login', credentials) .then(function (res) { console.log(res.data); Session.create(res.data._id, res.data.email); return res.data; }); }; authService.signup = function (credentials) { console.log(credentials.username) return $http .post('/api/signup', credentials) .then(function (res) […]

如何添加一个模块Angular在Pencilblue?

所以我正在build立这个Pencilblue网站。 Pencilblue基于MEAN堆栈。 我正试图让searchfunction。 我需要声明一个模块。 Pencilblue是这样的: ClientJs.getAngularController = function(objects, modules, directiveJS) { if(!util.isArray(modules) || modules.length > 0) { modules = ['ngRoute']; } var angularController = 'var pencilblueApp = angular.module("pencilblueApp", ' + JSON.stringify(modules) + ')'; 所以第二行是告诉我模块从别的地方加载,除非没有,在这种情况下, modules = ['ngRoute']; 应该加载。 我想到的是这样的: ClientJs.getAngularController = function(objects, modules, directiveJS) { if( modules.length > 0) { modules = ['ngRoute', 'elasticui']; } […]

使用适用于Visual Studio的Angular和NodeJS工具构buildNodeJS应用程序

我想知道在使用nvst构buildNodeJS应用程序时,通常如何组织您的应用程序结构。 当我创build我的应用程序时,它会自动为我构build这个结构: 所以,我想到的第一件事情是,我应该在哪里放置控制器,以及如何将它们与路线和视图连接起来? 另外,我怎样才能组织我的unit testing逻辑?

在Node.js / Express和AngularJS中创buildCORS请求

我已经看到很多堆栈溢出的答案,说设置响应头会让你“CORS”request.But没有解决scheme为我工作。我写了下面的代码: //Server.js Code var express = require('express'), app = express(); app.all('*',function(req, res, next) { res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.setHeader('Access-Control-Allow-Credentials', true); res.setHeader('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, OPTIONS'); next(); 我试图从客户端使用$ http访问URL中的内容: //Controller.js $http.get('http://domainA.com/a/ipadapi.php?id=135&client=ipad').success(function(response){ alert("I got response"); }); 它在控制台中显示以下错误。 XMLHttpRequest cannot load http://domainA.com/a/ipadapi.php?id=135&client=ipad The 'Access-Control-Allow-Origin' header has a value 'http://example.xxxxx.com' that is not equal to […]

使用量angular器+ Appium + SauceLabs

我一直在尝试自动对移动我的量angular器testing。 我已经阅读了大部分的networking博客,我到达了这个与Saucelabs的Appium“官方”: https ://docs.saucelabs.com/tutorials/appium/#mobile-web-application我遵循指示在那里,并configuration我的config.js文件 var testName = 'Testing'; //Change Project's name here in order to be identified in BrowserStack exports.config = { // The address of a running selenium server. seleniumAddress: 'http://bmsoko:[redacted]@ondemand.saucelabs.com:80/wd/hub', // Capabilities to be passed to the webdriver instance. multiCapabilities: [{ name: testName, 'appium-version': '1.4.0', 'browserName': 'Android', 'deviceName': 'Android Emulator', 'deviceOrientation': 'portrait', 'platform': […]

如何使用swagger-ui模块在我的MEAN堆栈项目中显示Swagger JSON文件?

我是NodeJS和AngularJS的新手,所以我可能会接近完全错误,但值得问… 我正在尝试使用swagger-ui Node模块以交互式的Swagger-ish风格显示我的API文档。 我想在我的NodeJS应用程序中通过传入我自己的Swagger JSON文件(在public/assets/my-swagger.json )执行此操作。 我假设我可以做这样的事情: angular.module('SwaggerCtrl', []).controller('SwaggerController', function($scope) { $scope.swagger = new function() { var swaggerUi = new SwaggerUi({ url: '../../assets/my-swagger.json', dom_id: "swagger-ui-container" }); swaggerUi.load(); }; }); 从https://www.npmjs.com/package/swagger-ui#swaggerui取得 。 然后在我的swagger.html我会做这样的事情: <div class="jumbotron text-center"> <h1>Swagger</h1> <p>{{ swagger }}</p> <div id="swagger-ui-container"></div> </div> 但是,当我去http:// localhost:8080 / swagger ,我得到ReferenceError: SwaggerUi is not defined我的控制台上ReferenceError: SwaggerUi is not defined错误信息。 […]