Showing posts from 2017

Catching exceptions and displaying error messages in view using Angular2

We can display cached error message in view from component for that need write the following code
in Appcomponent

export class AppComponent {
    iproducts: IProduct[];
    err: any;
    constructor(private _product: ProductService) {
    ngOnInit(): void {
          .subscribe(iproducts => this.iproducts = iproducts,
      error => this.err = error);

and in HTML Page or template we need to write  following code. Focus only on bold code rest of the code responsible for get values from service

    selector: 'my-app',
    template: `<h1>{{err}}</h1>`,

Constants in AngularJs

Constants can be injected everywhere including configuration calls. So when you call module.config and set up states,colors,months,weeks or other run time settings you can inject constant values.

<!DOCTYPEhtml><htmlng-app="app"><head><title></title><metacharset="utf-8"/><scriptsrc="Scripts/angular.min.js"></script></head><bodyng-controller ="MyController">{{title}}<script>var app = angular.module('app', []);         // Storing a single constant value         app.constant('MOVIE_SAMPLE', 'The Movie');         // Now we inject our constant value into a My controller         app.controller('MyController', function ($scope, MOVIE_SAMPLE){ $scope.title=MOVIE_SAMPLE; }); </script></body></html>

Create and Execute a Simple PLINQ Query


Pass user defined object to ASP.NET Webmethod from jQuery, using JSON