News Thursday, June 14

The new Angular HttpClient API – Angular In Depth

  • We can do: – Rather than: – However if you’re still interested in the whole Response object you can observe for it: – // HttpClient – this.http.get(‘…’, { observe: ‘response’ });Query parameters – One thing that might not be as intuitive is the way that it handles query parameters.
  • Type checking responses – Thanks to TypeScript Generics you type HTTP method youre calling and the response will get be of that same type: – interface LoginResponse { – accessToken: string; – accessExpiration: { – login: ‘foo’, – password: ‘bar’ – }).
  • As the Request and Response objects are immutablewhich makes it easier to predict and test, we use the clone method to mutate the Response object.
  • In a file upload example it would be like that: – const req = new HttpRequest(‘POST’, ‘upload/file’, file, { – requestProgress: .
  • subscribe(event = { – if (event.type === HttpEventType.UploadProgress) { – console.log(event.total, event.loaded); – } – });Wrapping up – The HttpClient API is awesome.

var request = new XMLHttpRequest(); request.open(‘GET’, “https://topfeed37.firebaseio.com/v1/pages/blog_angularindepth_com/_the_new_angular_httpclient_api_9e5c85fe3361_gi_c770d2618c68/twitter_poll/url.json”, true); request.onload = function() { if (request.status >= 200 && request.status < 400) { var tweet_url = JSON.parse(request.responseText); if (tweet_url !== null) { var poll = 'The new Angular HttpClient API – Angular In Depth‘; document.getElementById(‘tweet_poll’).innerHTML = poll; if (typeof twttr !== ‘undefined’) { twttr.widgets.load(); } } } else { } }; request.onerror = function() { }; request.send(); Tags:

The new Angular HttpClient API – Angular In Depth

Create Dynamic Components in Angular

  • Dynamic data gives us the opportunity to build dynamic components.
  • Dynamic components are reusable and make building large-scale applications so much easier.
  • In this course, Juri Stumpflohner will take us through the specific use case of of creating a tabbed component which allows us to dynamically define new tabs.
  • On our journey of implementing this component we will learn about how we can dynamically instantiate components, leveraging the and .
  • Furthermore we will explore how to define view templates, how to pass them to our dynamically instantiated components as well as how to pass data into those templates.

Tags:

Create Dynamic Components in Angular

Tags:

The post Angular, javascript, angular, appeared first on JSNews.



Source link https://jsnews.io/angular/angular-javascript-angular/

LEAVE A REPLY

Please enter your comment!
Please enter your name here