88 Matching Annotations
  1. Dec 2023
  2. May 2023
  3. Dec 2022
  4. Mar 2022
  5. Nov 2021
  6. Jun 2021
    1. Angular is nothing but an open-source web application framework. It is being led by the Angular Team at Google and also by a community of individuals and corporations. It is based on TypeScript.Angular is a complete rewrite from the same team that had built AngularJS. It can be used as the frontend of the MEAN stack, which consists of the MongoDB database, Express.js web application server framework, Angular itself (or AngularJS), and the Node.js server runtime environment.

      Top Angular 8 Interview Questions to get you ready

  7. Feb 2021
  8. Nov 2020
    1. But you can still run into strange race conditions where the browser displays stale data depending on if some other unrelated code has caused a digest update to run after the buggy code or not.
    2. Converting Angular components into Svelte is largely a mechanical process. For the most part, each Angular template feature has a direct corollary in Svelte. Some things are simpler and some are more complex but overall it's pretty easy to do.
    3. We don't use "attribute directives" much which makes things easier.
    4. Directives like ng-if="info.report.revenue" sort of work in Angular if info.report is undefined, in that the ng-if becomes false. But the Svelte equivalent {#if info.report.revenue} throws an error. For now we're using lodash get in places where we need to and looking forward to Svelte support for optional chaining.
    5. Embedding Svelte inside Angular is pretty easy, for the most part. I wrote a function that would take in a Svelte component and generate an Angular controller class.
    6. It's really helpful that Svelte stores are easy to use in plain JS. We can change a state store over completely to Svelte and make the Angular components subscribe to that store as well without needing to maintain and sync 2 copies of the state.
    1. The advantage of ngOnChanges() is that we get all the changes at once if the component has several @Input()s. However, if we have a single @Input() a setter is probably the better approach.
    1. A View is a fundamental building block of the application UI. It is the smallest grouping of Elements which are created and destroyed together.
    2. an Angular application is a tree of components
    1. Content is what is passed as children usually to be projected at some <ng-content> element of a component. View is the template of the current component. The view is initialized after the content and ngAfterViewInit() is therefore called after ngAfterContentInit().
    1. In Angular CLI 6 this command has been removed, and it will not come back. Instead there is a new concept called Builders.With the new Angular CLI you can customize the build process by defining your own builders as well as using one of the builders provided by the community.

      Why did they remove it if it was useful? They wanted people to be stuck in Angular CLI world? Couldn't they still provide that escape route / migration path for those that really do need/want to eject?

    2. In Angular CLI 1.x (Angular 5) you had ng eject command for this, which was ejecting the whole underlying webpack configuration and allowing you to modify it as you please.
  9. Oct 2020
    1. this.txtQueryChanged .debounceTime(1000) // wait 1 sec after the last event before emitting last event .distinctUntilChanged() // only emit if value is different from previous value .subscribe(model => { this.txtQuery = model;
    1. With Angular 2 we can debounce using RxJS operator debounceTime() on a form control's valueChanges observable:

      What's the React/Svelte equiv. pattern for this?

  10. Sep 2020
    1. I think Svelte's approach where it replaces component instances with the component markup is vastly superior to Angular and the other frameworks. It gives the developer more control over what the DOM structure looks like at runtime—which means better performance and fewer CSS headaches, and also allows the developer to create very powerful recursive components.
    1. being able to compose multiple components' functionality via decoration (not creating new "combo" components or something) is more elegant, and something I wish React had.
    2. The whole point of directives is composability. First: you can apply a directive to any component, even components included from other libraries. Second: you can apply multiple directives to the same component. Directives are decorators, so it's not the same thing.
  11. Aug 2020
    1. The let keyword declares a template input variable that you reference within the template. The input variables in this example are hero, i, and odd. The parser translates let hero, let i, and let odd into variables named let-hero, let-i, and let-odd.
  12. Apr 2020
    1. SPAs are incredibly common, popularised by client-side web frameworks like Angular, React and Vue.js.


      • popularised by client-side web frameworks like Angular, React and Vue.js
      • real difference between the MVP app is shifting most of its work on the client side
      • there's client side MVC, MVVM (model-view-view-model) and FRP (functional reactive programming)

      Angular - client side MVC framework following its pattern, except it's running inside the users web browser.

      React - implementation of FRP. A little more flexible, but more concerned with state change events in data (often using some event store like Redux)

    1. online Angular Training which has been designed by the industry experts which will help you to create web applications and deploy Angular CLI

      Check this for Angular Course from Intellipaat.

  13. Nov 2019
  14. Oct 2019
    1. I'm super stoked about Vue.js though...I'm kind of over Angular at this point since it left a bad taste in my mouth last year (it's a much larger framework and the 'official' build system isn't even being used anymore by programmers)
    2. I'm doing a newer project in Vue.js because it looks much lighter than Angular and just awesome all around
    3. Been there, done that. Vue.js takes the best ideas form Angular (and some from React), without putting you in ZoneAwareError hell.
  15. Sep 2019
  16. May 2019
    1. But like its usual in the case of Observable-based APIs, FRP techniques can help easily implement many use cases that would otherwise be rather hard to implement such as: pre-save the form in the background at each valid state, or even invalid (for example storing the invalid value in a cookie for later use) typical desktop features like undo/redo

      key point on why FRP is good: misc usages on each 'state' change in the form - record and save state for 'undo' feature, save to local storage to be recovered later, etc

    2. This is why this is called template-driven forms, because both validation and binding are all setup in a declarative way at the level of the template.

      key point on naming of 'template-driven forms'

    3. You are probably wondering what we gained here. On the surface there is already a big gain: We can now unit test the form validation logic

      key point - advantage of reactive forms is the testability of its validation

  17. Dec 2018
    1. Then inject it inside a test by calling TestBed.get() with the service class as the argument. it('should use ValueService', () => { service = TestBed.get(ValueService); expect(service.getValue()).toBe('real value'); });

      this is for testing the service, directly

    2. However, you almost always inject service into application classes using Angular dependency injection and you should have tests that reflect that usage pattern. Angular testing utilities make it easy to investigate how injected services behave.

      key point

    1. We can even remove the AuthService import if we want, there really is no dependency on anything else. The LoginComponent is tested in isolation:

      that's a key point - isolating stuff. remember this is unit testing, not integration tests. we wish to have as little as dependencies as possible.

    2. That’s not very isolated but also not too much to ask for in this scenario. However imagine if LoginComponent required a number of other dependencies in order to run, we would need to know the inner workings of a number of other classes just to test our LoginComponent. This results in Tight Coupling and our tests being very Brittle, i.e. likely to break easily. For example if the AuthService changed how it stored the token, from localStorage to cookies then the LoginComponent test would break since it would still be setting the token via localStorage.

      key points - this shows the benefits (easy) of this kind of testing and its disadvantages (coupled, easy to break if a service changes its implementation)

  18. Nov 2018
    1. Mocking localStorage is optional, but without mocking getComputedStyle your test won’t run, as Angular checks in which browser it executes. We need to fake it.

      key point

    1. Or inside the beforeEach() if you prefer to inject the service as part of your setup. beforeEach(() => { TestBed.configureTestingModule({ providers: [ValueService] }); service = TestBed.get(ValueService); });

      this corresponds with the option mentioned above - inject it inside a single test

  19. Oct 2018
  20. Sep 2018
    1. This is known as the entry file.

      Key point

    2. When we use ng new the Angular CLI creates a new workspace for us.In our Angular workspace we are going to have two projects:A library projectThis is the library of components and services that we want to provide. This is the code that we could publish to npm for example.An application projectThis will be a test harness for our library. Sometimes this application is used as documentation and example usage of the library.

      Good ideas about what to do with the needed 'application' that we are forced to create just to create the library.

    1. When we’ve generated the library (ng generate library tvmaze ) Angular CLI modified the tsconfig.json in the root of our project by adding tvmaze to the paths entry.

      Read - this is how to fake a local library to be imported by TS as if it was in node_modules

    2. Why is that useful? It enables such service to be tree-shaken (removed form the production bundle if not used)

      Very important note - useful!

  21. Aug 2018
    1. Then it gets the native element of the compiled HTML (the HTML rendered by the component).

      This explains what 'native element' is, at least in this case. Its the outcome HTML after the detectChanges()

    2. We use an async before each. The purpose of the async is to let all the possible asynchronous code to finish before continuing.

      Is this like putting your code in setTimeout() just to push it into the event loop task queue?...

    1. The CLI takes care of Jasmine and karma configuration for you.

      meaning, creating a new app using ng new will create the needed mentioned (below) config files

    1. The custom id is persistent. The extractor tool does not change it when the translatable text changes. Therefore, you do not need to update the translation. This approach makes maintenance easier

      key point! it allows English speaking site without worrying about translations at all, and keeping translation unit keys constant over time even if the English text is changing

    2. The Angular extraction tool preserves both the meaning and the description in the translation source file to facilitate contextually-specific translations, but only the combination of meaning and text message are used to generate the specific id of a translation. If you have two similar text messages with different meanings, they are extracted separately. If you have two similar text messages with different descriptions (not different meanings), then they are extracted only once

      important - this is how the 'keys' for the translation person are extracted - what determines the singularity of the translation item.

    3. You need to build and deploy a separate version of the app for each supported language

      key point!

    4. The CLI imports the locale data for you when you use the parameter --configuration with ng serve and ng build

      See sample i18n app (link in the beginning of this document). Basically, in package.json: "scripts": { "start": "ng serve", "start:fr": "ng serve --configuration=fr", "build": "ng build --prod", "build:fr": "ng build --configuration=production-fr",

    1. To define a class as a service in Angular, use the @Injectable() decorator to provide the metadata that allows Angular to inject it into a component as a dependency. Similarly, use the @Injectable() decorator to indicate that a component or other class (such as another service, a pipe, or an NgModule) has a dependency.

      This means that the 'injectable' decorator has two meanings and two usages. I think this wasn't so in the past.

  22. Jul 2017
    1. retire our default home page that is built with a Jade view, and instead use an Angular view

      use Angular view instead of Jade view

  23. Mar 2017
  24. Feb 2017
    1. how it uses zones

      Does anyone have an authoritative link for this concept of zones and how they work? It'd be much appreciated.

    2. In general, add providers to the root module so that the same instance of a service is available everywhere.

      So, from this I take it that once a Service is added to the root module, it can be used by any component of that module.

      What about the components imported, from sub-modules of the root one? Can their dependency needs be met, in similar fashion? For example, could a Component in another module (imported into the root one) just request a Service provided in the root module and have it properly injected from there, without anything else on the developer's part?

    3. you get a new instance of the service with each new instance of that component

      So, I take it that the Service instance will not be a singleton anymore? Whereas, if provided from the root module, it will?

  25. Jan 2017
    1. Component classes should be lean. They don't fetch data from the server, validate user input, or log directly to the console. They delegate such tasks to services.

      A really good point! Lean-ness is something to strive for.

    2. While a component is technically a directive, components are so distinctive and central to Angular applications that this architectural overview separates components from directives.

      As per the MVVM pattern, they sort of provide the support for the View. They are like the glue for the visual representation of a part of the application. A controller of sorts (but not quite one) of MVC.

    3. other metadata decorators

      A somewhat comprehensive list of the currently available class decorators and their roles can be found in the Official Angular Cheat Sheet.

  26. Dec 2016
  27. Aug 2016
    1. function(context, locals)

      context.locals as seen in a plunkr example

      var template =$parse( "libs[i]" ) ; this.libs=["ng" ," jquery", "bootstrap"] ; for(i= 0; i< this.libs.length; i++) {

      output = output + '

    2. ' + **template(this, {i: i}) **+ '
    3. '; this.parsedMsg = 'The project uses
        ' + output + '
      '; [ link here - http://plnkr.co/edit/IXo5QqKNfhCsnOGLzM4J?p=preview]


  • May 2016
    1. bower_components

      Ionic installs bower components (bower packages) into the project's lib folder:


      This behaviour is defined in the projects .bowerrc file, which looks like this:

        "directory": "www/lib"

      The project .bowerrc file may be found at the same level as the www folder.

      Note that if you install angular-chart this way, you don't need to install Chart.js separately; it is one of the dependencies that bower will install for you. Of course, you must include the script tag that references the Chart.js file as usual!

      Finally, if you want to link angular-chart.css you must follow the same procedure.

  • Mar 2016
    1. The basic argument here is that templates have an advantage because they are constrained compared to allowing component structure to be defined in arbitrary JS is valid.

  • Jan 2016
  • Aug 2015
    1. Angular 2 embraces web platform standards, so it puts the view of the component in the Shadow DOM of the element where it has been created. If your browser does not support Shadow Dom, Angular will emulate it on a par with native shadow DOM.

      At the time this was written I don't think vendors were anywhere near agreement on several major aspects of shadow DOM

  • Jun 2015