Tag: angularjs

$ https删除不能在nodejs和mongodb中工作,无法删除

身份证即时进入控制器,但nt进入服务器,当我点击删除我在控制台中得到的ID。 它显示错误“可能未处理的拒绝”和错误404 这是我的服务器: var express=require('express'); var mongojs=require('mongojs'); var bodyParser=require('body-parser'); var app=express(); var db=mongojs('contactlist',['contactlist']); app.use(express.static(__dirname + "/public")); app.use(bodyParser.json()); app.get('/Contactlist',function (req,res) { console.log("ireceived a get request") db.contactlist.find(function (err,docs) { console.log(docs); res.json(docs); }) }) app.post('/Contactlist',function (req,res) { db.contactlist.insert(req.body,function (err,doc) { res.json(doc); console.log(doc); }) }) app.delete('/contactlist/:id',function (req,res) { var id= req.params.id; console.log(id); }) app.listen(3000); console.log('Server running on port 3000'); […]

无法让Angularjs在渲染模板之前等待数据

我看了很多教程和堆栈溢出页面,但没有解决scheme为我工作。 基本上,我需要在将数据传递给模板之前从Firebase获取数据。 这可能也可能不重要,但我在后端使用nodejs和ejs。 但问题是与angular1 码 angular.module("example", ["elif", "ngRoute"]) .config(['$routeProvider', function($routeProvider) { $routeProvider .when("/leaders", { templateUrl: "leaders", controller: 'LeadersController', resolve: { data: function () { return getLeadersData(); } } }); }]) .controller('LeadersController', ["$scope", "$http", "$location", "$window", 'data', function($scope, $http, $location, $window, data) { $scope.data = data; }]); function getLeadersData() { // firebase does its thing and […]

没有导出成员Angular

[为什么红色波浪错误] 在视觉stdio错误 错误光幕 '“/Users/dev/pratice_workspace/quickstart/src/app/components/language.component”'没有导出成员'LangugeComponent'。 导入LangugeComponent 在Chrome控制台中出错 ZoneAwareError __zone_symbol__error:错误:(SystemJS)模块'AppModule'声明的意外值'undefined'错误:模块“AppModule”在SyntaxError.ZoneAwareError声明的意外值'undefined' app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { LangugeComponent } from './components/language.component'; @NgModule({ imports: [BrowserModule], declarations: [AppComponent, LangugeComponent], bootstrap: [AppComponent] }) export class AppModule {} language.component.ts import { Component } from '@angular/core'; @Component({ selector: […]

如何在我的angular度js应用程序中正确设置checklist-model指令?

我是一个noob与node.js /咕噜世界,所以我很抱歉,如果这个问题是非常愚蠢的… … – 我有一个与yeoman / grunt一起工作的angular.js项目,现在我想要做的就是包含一个指令,特别是这个指令, 但我不知道如何安装它! 我有: 在我的命令提示符下使用命令npm install checklist-model 链接index.html文件内的脚本 <script src='node_modules/checklist-model/checklist-model.js'></script> – 并在我的应用程序中添加依赖项 var app = angular.module('generaPreventivoApp', [ 'ngAnimate', 'ngCookies', 'ngResource', 'ngRoute', 'ngSanitize', 'checklist-model' ]); 控制台给我以下错误: Error: [$injector:modulerr] Failed to instantiate module app due to: [$injector:modulerr] Failed to instantiate module checklist-model due to: [$injector:nomod] Module 'checklist-model' is not available 我怎样才能正确设置?

在Angular 2应用程序中使用本地npm仓库中的组件

我已经使用d3和Angular 2实现了一个通用的图表组件。然后将它发布到本地的npm仓库中,以便任何人只要运行npm install my-chart命令就可以在他们的Angular项目中使用这个图表组件。 我创build了一个基本的Angular 2项目来重用我的图表组件。 然后运行npm install my-chart –save ,向package.json添加“@ my / my-chart”:“^ 1.0.0” 。 但运行服务器时出现问题,它会在我的控制台上提示错误。 Module not found: Error: Can't resolve 'd3' in '…\node_modules\@my\my-chart' 我需要在我的Angular项目中安装D3吗? 但是我觉得在我们运行npm install my-chart的时候,把d3和图表组件捆绑在一起会更好。 什么是最好的? 已发布软件包的package.json文件: { "name": "@my/my-chart", "version": "1.0.2", "license": "MIT", "angular-cli": {}, "author": "rosew", "main": "./index.js", "keywords": [ "button", "card" ] } 消费包的package.json文件: "dependencies": { "@angular/common": […]

有什么方法可以限制ng-repeat中的重复项目的数量?

有没有什么办法可以限制AngularJS中重复的项目数量? 就像在联系人列表中,我需要input相同的姓名和联系电话号码,但只有2次,当我试图进入第三次时,它显示我一些警告,你已经input联系方式。 我怎样才能通过使用AngularJS或JavaScript来实现这个任务? 我的代码是 <md-list-item ng-show="showContactList" ng-repeat="numbers in contactList track by $index" > <i ng-show="numbers.type == 'test'">textsms</i> <i ng-show="numbers.type == 'CELL' || numbers.type == 'EXT'">phone</i> <img ng-show="numbers.type == 'PAGER'" src="pager.png" width="26"> <div class="md-list-item-text" ng-class="{'md-offset': phone.options.offset }"> <h3>{{ numbers.type }}</h3> <p>{{ numbers.value }}</p> </div> <i ng-click="arrayText.push(numbers);">add</i> </md-list-item> 在上面的代码中,我可以添加N号码来联系姓名和号码。

对服务器中文件的连续写入很慢

我想用MEAN模块构build一个简单的操作系统,模拟plunker:我们有一个文件列表,左侧是textarea,右侧是实时预览。 请注意,文件保存在临时文件夹中,实时预览是由临时文件夹中的文件注入的iframe 。 我编写了一些东西。 在前端,控制器监视textarea中文件的修改; 每次有变化, render将被调用,它会发送一个$http.post来保存所有文件的新版本。 app.controller('Ctrl', ['$scope', 'codeService', function ($scope, codeService) { … $scope.$watch('files', function () { codeService.render($scope.files) }, true); }]); app.service('codeService', ['$http', function ($http) { this.render = function (files) { … var arrayLength = files.length; for (var i = 0; i < arrayLength; i++) { $http.post('/writeFile', files[i]); } } } 在后端: router.post('/writeFile', […]

使用gulp-useref如何添加额外的文件?

我的HTML文件是这样的: … <!– build:js build/js/vendor.js –> <script src="dep/angular/angular.js"></script> <!– endbuild –> 像这样构build文件: <script src="build/js/vendor.xxxxxxxx.js"></script> 现在我用gulp-angular-templatecache打包所有的视图文件,生成一个template.js,我想将这个文件添加到编译后的html文件里面,怎么做呢? 我在additionalStreams设置选项中find了gulp-useref文件,但是我用来find不想实现的function。

将JSON对象转换为CSV并将其保存到文件

用户按下button,它使用NodeJS对我的数据库执行SQL查询,结果是一个JSON对象(一个包含对象的数组)。 之后,结果必须保存在一个文件中(用户需要该文件)。 问题:它不能是一个JSON。 格式是由simbol“ ; ”分隔的值和每行一个对象。 我需要创build的文件内容的示例(它就像一个CSV): 1;tree;green 2;car;red 3;Robert's house;white 这个结果查询有大约18000行。 它很大。 我正在使用replace方法,但我有与罗伯特的房子 simbol像值的问题,因为控制台解释为string的开始。 然后在客户端使用: $window.open('data:text/csv,' + encodeURIComponent(myString)); 这里的符号“开始了这个问题。 我想知道如何将JSON转换为该格式(在NodeJS下)以及如何创build该文件。

模板的angular度路线

我无法让我的路线在我的Angular应用程序中工作。 它正确地显示主模板,但是当我点击其他模板的链接时,什么也没有发生。 这是我的代码: INDEX.HTML <!DOCTYPE html> <html> <head> <title>Node, NPM and Bower</title> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"> <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css"> <link rel="stylesheet" href="style.css"> </head> <body ng-app="app"> <nav> <h3>Angular App</h3> <a href="/">Home</a> <a href="/about">About</a> </nav> <div ng-view></div> <script src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="./app/app.js"></script> </body> </html> APP.JS angular.module("app", ["ngRoute"]). config(function($routeProvider) { $routeProvider .when("/", { template : "<h1>Home</h1>" }) .when("/about", […]