angular

How can I use a fake/mock/stub child component when testing a component that has ViewChildren in Angular 10+?

社会主义新天地 提交于 2021-02-10 14:33:25
问题 Before marking this as a duplicate of this question please note that I'm asking specifically about Angular 10+, because the answers to that question no longer work as of Angular 10. Background I've created a simple example app that helps illustrates my question. The idea with this app is that several "people" will say "hello", and you can respond to any or all of them by typing their name. It looks like this: (Note that the 'hello' from Sue has been greyed out because I responded by typing

How can I use a fake/mock/stub child component when testing a component that has ViewChildren in Angular 10+?

馋奶兔 提交于 2021-02-10 14:32:23
问题 Before marking this as a duplicate of this question please note that I'm asking specifically about Angular 10+, because the answers to that question no longer work as of Angular 10. Background I've created a simple example app that helps illustrates my question. The idea with this app is that several "people" will say "hello", and you can respond to any or all of them by typing their name. It looks like this: (Note that the 'hello' from Sue has been greyed out because I responded by typing

I'm getting this error when ran ng e2e: Could not find update-config.json

孤街浪徒 提交于 2021-02-10 14:31:14
问题 Currently I have Protractor v.5.4.2, Node.js v.10.15.39 [09:21:29] I/launcher - Running 1 instances of WebDriver [09:21:29] I/direct - Using ChromeDriver directly... [09:21:29] E/direct - Error code: 135 [09:21:29] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.driver-manager update' to download binaries. anager update' to download binaries. [09:21:29] E/direct - Error: Could not find update-config.json. Run 'webdriver-mes

Angular - Getting out of Zone.JS for specific callbacks

倖福魔咒の 提交于 2021-02-10 14:25:43
问题 First and foremost, I'm well aware of zone.runOutsideAngular(callback) , documented here . What this method does is running the callback in a different zone than the Angular one. I need to attach a very quick callback to document 's mousemove event (to count Idle time). I don't want to have the whole Zone.JS machinery of tasks appended to execution queues for this specific callback. I would really like to have the callbacks run in plain, unpatched browser runtime. The event registration code

Error building with ng build --prod. Fine without --prod flag and ng serve

痴心易碎 提交于 2021-02-10 14:23:33
问题 I have a project that built fine with ng build --prod until I upgraded the version of TypeScript from 2.72 to 2.92 in my package.json. After upgrading, I now get the following error: ERROR in Cannot read property 'Symbol(Symbol.iterator)' of undefined However, the project builds fine using ng build and runs fine using ng serve so I have no idea where this problem is occurring and the error doesn't tell me where the problem is in my project. 回答1: I found the issue. Using resolveJsonModule

Typescript Export enum based on the condition?

旧巷老猫 提交于 2021-02-10 14:21:01
问题 Angular based on the environment I need to export enum. I don't know wether it is correct or not? role.ts import { environment } from '../../environments/environment'; if(environment.production) { export enum Role { User: 'user', Admin: 'admin' } } else { export enum Role { User: 'user', Admin: 'user' } } Based on the condidtion how to export it? Thanks 回答1: You can do it like this: import { environment } from '../../environments/environment'; export class Role { static User = 'user'; static

How can Angular 4 use with Laravel 5.5 together?

徘徊边缘 提交于 2021-02-10 14:14:40
问题 I know that angular can integrate with some frameworks. I want to use angular version 4 into Laravel version 5.5 but I don't know how to setup the application. It is possible that I install angular CLI into Laravel project? Which solutions is the best for building app with angular ( integrate with framework or separate two projects)? 回答1: I am assuming you have the understanding about Angular and Laravel. I have used Angular(2+) and Laravel in many projects. Angular is for front-end

ReferenceError: window is not defined Angular Universal

自古美人都是妖i 提交于 2021-02-10 14:14:38
问题 I'm using Angular 10 and trying to implement SSR in my project. When I run the npm run serve:ssr I'm getting the below error ReferenceError: window is not defined When I googled, they suggested to add domino So below is my server.ts .... const scripts = fs.readFileSync('dist/asfc-web/browser/index.html').toString(); const window = domino.createWindow(scripts); global['window'] = window; global['document'] = window.document; .... still getting the same error, Please guide me how to resolve

ReferenceError: window is not defined Angular Universal

扶醉桌前 提交于 2021-02-10 14:14:35
问题 I'm using Angular 10 and trying to implement SSR in my project. When I run the npm run serve:ssr I'm getting the below error ReferenceError: window is not defined When I googled, they suggested to add domino So below is my server.ts .... const scripts = fs.readFileSync('dist/asfc-web/browser/index.html').toString(); const window = domino.createWindow(scripts); global['window'] = window; global['document'] = window.document; .... still getting the same error, Please guide me how to resolve

Angular - wait for this variable to have value and then execute

霸气de小男生 提交于 2021-02-10 14:13:45
问题 In ngOnInit() , first line of code fetches the value from local storage and then that value is used to filter data from database. Both executes together and I don't get the result. How can I do something like the second function waits for the first one to get value. Below is my ts code: ngOnInit() { //get id of user this.storage.get('loggedInUser').then((val) => { console.log('Your user ID is', val); this.loggedInusr = val; }); firebase.firestore().collection(`todos`) .where("assignTo", "==",