angularjs

Angular: What's the correct way to return Observable?

萝らか妹 提交于 2021-02-11 13:38:33
问题 I have the following method which isn't working correct: getProducts(): Observable<Product[]> { let PRODUCTS: Product[]; this.http.get(this.base_url + "api/products") .subscribe( (data) => { for(var i in data) { PRODUCTS.push(new Product(data[i].id, data[i].name, data[i].category, data[i].description, data[i].price, data[i].amount)); } }, (error) => { console.log(error); }); return of(PRODUCTS); } The error I'm getting is this: TypeError: Cannot read property 'push' of undefined Now, I know

Jasmine Karme Unit test - AngularJs Directive is not getting compiled

[亡魂溺海] 提交于 2021-02-11 12:58:08
问题 I am having issues testing angularjs directive. Following is my test: it('should be defined', inject(function($compile,$rootScope){ $scope = $rootScope.$new(); element = $compile('<div><some-directive-name></some-directive-name></div>')($scope); $scope.$digest(); console.log(element[0].outerHTML); expect(element.html()).toBe(template); })); Output for the console.log comes as '<div class="ng-scope"><some-directive-name></some-directive-name></div>' Instead it should be the template URL of

Jasmine Karme Unit test - AngularJs Directive is not getting compiled

吃可爱长大的小学妹 提交于 2021-02-11 12:56:27
问题 I am having issues testing angularjs directive. Following is my test: it('should be defined', inject(function($compile,$rootScope){ $scope = $rootScope.$new(); element = $compile('<div><some-directive-name></some-directive-name></div>')($scope); $scope.$digest(); console.log(element[0].outerHTML); expect(element.html()).toBe(template); })); Output for the console.log comes as '<div class="ng-scope"><some-directive-name></some-directive-name></div>' Instead it should be the template URL of

AngularJS: How to unselect a span when selecting another

十年热恋 提交于 2021-02-11 12:35:10
问题 I have a list of things that I display with ngrepeat that when they are clicked, produce an additional list of things pertaining to the element selected. My intent is to have the clicked element's background change color so as to show it selected. My issue is when I select another element, they both show as selected. Here is my code: <div class="breakdownRow pointer" ng-class="{bSelection: selection}" ng-click="selection=true" ng-repeat="m in masterList"> <span class="areaTag">{{m.area}}<

Node JS Nodemailer POST internal server error 500

浪尽此生 提交于 2021-02-11 10:37:05
问题 Hi all I am trying to send email from my website with nodemailer and express routing after press send button i have info /contactForm 500 internal server error any idea how to solve it. //app.js // CONFIG const express = require('express'); const app = express(); const exphbs = require('express-handlebars'); const compression = require('compression'); const config = require('./src/server/config/config'); const http = require('http'); const path = require('path'); const cookieParser = require(

Console logging object shows 2 different values

笑着哭i 提交于 2021-02-11 10:15:23
问题 This is insane, or is it?! If I access departuredate directly I get the correct value of 2016-05-18. console.log(searchFactory.search.searchparams.journeys[0].departuredate); // 2016-05-18 console.log(searchFactory.search.searchparams.journeys[0] //stored in the object as 2010-05-10 However if I console.log() the entire object as in the attached screenshot, it is reset to todays date. How is that even possible? Ultimately the value is assigned to my Factory, which ends up being 2016-05-10 -

Console logging object shows 2 different values

Deadly 提交于 2021-02-11 10:13:15
问题 This is insane, or is it?! If I access departuredate directly I get the correct value of 2016-05-18. console.log(searchFactory.search.searchparams.journeys[0].departuredate); // 2016-05-18 console.log(searchFactory.search.searchparams.journeys[0] //stored in the object as 2010-05-10 However if I console.log() the entire object as in the attached screenshot, it is reset to todays date. How is that even possible? Ultimately the value is assigned to my Factory, which ends up being 2016-05-10 -

AngularJS - prevent ng-keydown trigger ng-blur

本小妞迷上赌 提交于 2021-02-11 08:51:47
问题 i'm working with angularJS and i need a way to stop the execution of ng-blur when ng-keydown is executed, since ng-keydown at some point makes the element lose the focus. The html is: <div contenteditable ng-show="contentEditableSupport" ng-init="oldName = ''" ng-focus="oldName = userGroup.name" ng-model="userGroup.name" strip-br="true" ng-blur="editName(userGroup, oldName)" ng-keydown="$event.keyCode === 13 && editName(userGroup, oldName)">{{userGroup.name}}</div> The angular attribute

CSS Transition item in and out of flexbox smooth animation

隐身守侯 提交于 2021-02-11 07:41:16
问题 I'm building basic navigation for a website, and the graphical/animated functionality that I would like is this: 1: When in the 'HOME' state, the site logo/icon is large and centered and above the rest of the navigation/page links. 2: When on any other page than home, the logo/icon is smaller, and sits proportionally in a horizontal flexbox with the other elements. 3: There is a smooth transition between these two states. I've implemented this already as you can see below, but the transition

CSS Transition item in and out of flexbox smooth animation

怎甘沉沦 提交于 2021-02-11 07:34:36
问题 I'm building basic navigation for a website, and the graphical/animated functionality that I would like is this: 1: When in the 'HOME' state, the site logo/icon is large and centered and above the rest of the navigation/page links. 2: When on any other page than home, the logo/icon is smaller, and sits proportionally in a horizontal flexbox with the other elements. 3: There is a smooth transition between these two states. I've implemented this already as you can see below, but the transition