In Angular document, * and template, we know that the *ngIf, *ngSwitch, *ngFor can be expanded to ng-template tag. My question is: I think the ngIf or ngFor without * can also be translated and expanded to template tag by Angular engine. The following code would be the same as So why bother designing a strange symbol asterisk(*) in Angular?
Tag: angular
Typescript: is not assignable to type error
I am new to using typescript with angular 2. I am using version 1 of angular 2-cli. When compiling, I get this error saying “is not assignable to type Assignment[]”. I looked at the data types and it looks okay so far, but I am not sure what the error is exactly. Thanks for your help. Here is a photo
Angular 2 How to detect back button press using router and location.go()?
I have built an app that uses router 3.0.0-beta.1 to switch between app sections. I also use location.go() to emulate the switch between subsections of the same page. I used <base href=”/”> and a few URL rewrite rules in order to redirect all routes to index.html in case of page refresh. This allows the router to receive the requested subsection
Angular 2 not updating until any object is clicked
The following is something I’m trying to get working based on the Angular Tutorial. And the View sobots.data looks to be returning the data object as expected – however it’s still not updating until I click on any button/route/any event is fired. No errors show up in the console and I’m quite confused! I’ve gone ahead and tried to ensure
Angular2 : render a component without its wrapping tag
I am struggling to find a way to do this. In a parent component, the template describes a table and its thead element, but delegates rendering the tbody to another component, like this: Each myResult component renders its own tr tag, basically like so: The reason I’m not putting this directly in the parent component (avoiding the need for a
google sign-in with angular2 and typescript – where to get gapi?
I’m trying to use google sign-in with angular2 by following this question: Google Sign-In for Websites and Angular 2 using Typescript But I’m getting an error: Evidently gapi isn’t defined – which I can understand as I seem to only be declaring an empty var. My current code is as below: The template loads fine, it is just the gapi
Angular: In which lifecycle hook is input data available to the Component
I have a component which receives an array of image objects as Input data. I would like when the component loads the selectedImage value be set to the first object of the images array. I have tried to do this in the OnInit lifecycle hook like this: this gives me an error Cannot read property ‘0’ of undefined which means
Why is ngOnChange not detecting @Input element change whil ngOnDetect was able to do so
Consider this plunker Note: To observe the effect you have to rerun the app after the entering the link If I try to print out this.sub_list in Sub’s ngOnChange the browser outputs an empty list. However we can see that ngDoCheck still correctly captures the change. Is there a specific reason for this? Answer In your case ngOnChanges won’t be
Angular: conditional class with *ngClass
What is wrong with my Angular code? I am getting the following error: Cannot read property ‘remove’ of undefined at BrowserDomAdapter.removeClass Answer Angular version 2+ provides several ways to add classes conditionally: type one type two and multiple option: type three type four You can find these examples on the documentation page
How can I share an Angular 2 component between multiple Angular 2 projects?
Ideally, I’d like to create a stand-alone Angular 2 component (with tests) and then re-use it between two or three different Angular 2 sites. What are the good ways to achieve this? And a bonus question – do any 3rd party Angular 2 components exist? Answer UPDATE OFFICIAL Angular CLI https://angular.io/guide/creating-libraries You can create an angular2 component library (with tests)