Getting started with Angularjs and webapi

  • _service = service;

    // GET: api/Product
    public IEnumerableProduct Get()

    var products = _service.GetAllProducts();
    return products;



    public class ShoppingService: IShoppingService
    private readonly IRepositoryCategory _categoryRepository;
    private readonly IRepositoryProduct _productRepository;
    private readonly IRepositoryImage _imageRepository;
    public categoryRepository,
    IRepositoryProduct productRepository, IRepositoryImage imageRepository)

  • _imageRepository = imageRepository;


    public ListProduct GetAllProducts()
    return _productRepository.GetAll();

    public ListCategory GetAllCategories()
    return _categoryRepository.GetAll();


    public class ProductRepository : IRepositoryProduct
    private readonly DataContext _dbContext;

    public ProductRepository(DataContext dbContext)
    _dbContext = dbContext;
    public ListProduct GetAll()
    return _dbContext.Products.ToList();


    Since we use sqlcompact file to store our data, we need to install sql compact package from nuget, point the sql connection to add name=”DefaultConnection” connectionString=”Data Source =|DataDirectory|Tourism.sdf” /

    Then install sql compact package from nuget, point the sql connection to add name=”DefaultConnection” connectionString=”Data Source =|DataDirectory|Tourism.sdf” /

    Now we just finished writing web api to retrieve data from sql compact file.

  • If the web api is working as expected, I now start creating the single page app, install angularjs App = angular.module(‘App’, [‘ngRoute’]);

    // configure our routes
    App.config(function ($routeProvider) {

    // route for the home page

  • index.html

    body ng-app=”App”
    div class=”navbar navbar-inverse navbar-fixed-top”
    div class=”container”
    div class=”navbar-header”
    button type=”button” class=”navbar-toggle” data-toggle=”collapse” span class=”icon-bar”/span
    span class=”icon-bar”/span
    span class=”icon-bar”/span
    a href=”#/” title=”SPA – TechFunda” class=”navbar-brand”SPA/a
    div class=”navbar-collapse collapse”
    ul class=”nav navbar-nav”
    li class=”active”a href=”#/”Home/a/li
    lia href=”#/PD”Personal Details/a/li
    lia href=”#/about”About us/a/li
    lia href=”#/contact”Contact us/a/li
    div class=”container body-content”

    div id=”divLoading” ng-show=”loading” style=”font-size:50px;”
    div class=”loading”
    Loading …..
    div ng-view/div
    hr /


    The ng-app value needs to be same as the what is defined in the js.

  • Url}}” style=”height:250px;” alt=””

    div class=”caption price-color”
    h4 h4
    div class=”caption description-color”
    div class=”caption description-color”


    Each child view has its own controller, and it is responsible for retrieving and rendering the data in the view.

; Author: honzha99; Updated: 19 Feb 2017; Section: ASP.NET; Chapter: Web Development; Updated: 19 Feb 2017
Continue reading “Getting started with Angularjs and webapi”

Using multiple dependencies in an Angular.js application

  • Here’s the deal : we have a website which contains lots of pictures, and we want to “visualize” some data.
  • The way to go is using ZingChart (my favorite charting library) and a lazy loader (ing-src-ondemand) with our Angular.js app.The lazy loader will display (load) each picture only when they appear on the screen, via a scroll event.Those two features will add custom directives that can be used with our HTML template to bind the data from the controller (“ZingChart” will use a JSON file, and the lazy loader will take care of the pictures located in a $scope array).
  • To do this, we need to we download the libraries, available online we have them available on local (well, working with local files is, imho, better than depending on the CDN…), we have to load them from the HTML template :script we have to add those dependencies to our app.js file, which can be external, or attached just before the /body tag [‘zingchart-angularjs’, that’s it !
  • But I warn you : do not forget to load the libraries, or your app will not work at all, as the needed dependencies will be missing.

Continue reading “Using multiple dependencies in an Angular.js application”

Full Stack Web Development

Full Stack Web Development from The Hong Kong University of Science and Technology. Learn front-end and mobile hybrid development, build back-end …
Continue reading “Full Stack Web Development”

15 Best Resources for Developers to Learn AngularJS

15 Best Resources for Developers to Learn AngularJS
 via @codecondoltd #angularjs #developers

  • A lot of popular applications, such as Betrend and PunchPlay have made AngularJS a preferred choice as lot of AngularJS Tools  and Directives are available for developers to develop different types of apps using it.
  • It has two video tutorials covering around 50 examples of single-page app development concepts, foundational libraries and other AngularJS features.
  • Udemy offers a complete AngularJS course comprising 54 instructional video lectures that cover various important topics.
  • The course features instructional video tutorials and abundant resources that will help you to become a professional application developer using AngularJS and MEAN stack.
  • Egghead is resourced with several short video tutorials covering basic concepts of AngularJS and its utility in application development.

July 1, 2015
Continue reading “15 Best Resources for Developers to Learn AngularJS”

Spring REST API + OAuth2 + AngularJS

  • When the client application needs to acquire an Access Token, it will do so after a simple form-login driven auth process:

    A quick note here is that the form login configuration isn’t necessary for the Password flow – only for the Implicit flow – so you may be able to skip it depending on what OAuth2 flow you’re using.

  • Next, we will configure our TokenStore to access the same database that authorization server uses to store access tokens:

    Note that, for this simple implementation, we’re sharing the SQL backed token store even though the Authorization and Resource servers are separate applications.

  • Let’s start with the two simple pages – “index” and “login”; once a user provides their credentials, the front-end JS client uses them to acquire an Access Token from Authorization Server.
  • Here is our simple index page:

    As we will need to authorize our requests to the resource using our access token, we will append a simple authorization header with access token:

    If no cookie is found, the user will be redirected to login page.

  • Our client application is a separate module that tries to access resources server after obtaining an access token from authorization server using implicit grant flow.

Learn how to set up OAuth2 for a Spring REST API and how to consume that from an AngularJS client.
Continue reading “Spring REST API + OAuth2 + AngularJS”

Journal: How to embed Vue.js & Vuex inside an AngularJS app… wait what?

  • With Vuex, a new possibility presented itself—what if I built time-tracking as a Vue app within Cushion?
  • Vue’s view model instance is incredibly lightweight and performant, so when a user switches to the time-tracking tab, Cushion can mount the instance and make any requests to the API from Vuex.
  • Now, I can reference the Vue app’s state across the rest of Cushion and inject it into any Vue instance by simply specifying the store.
  • On top of that, this opens up a way for me to migrate Cushion from Angular to Vue in steps, rather than rewriting the entire app all at once.
  • I could rewrite the Angular controllers as Vue instances, and simply create new store modules in Vuex.

Since launching Cushion a couple years ago, we’ve been using AngularJS (1.x) as our front-end framework. If you’re curious how we ended up with Angular, I wrote about the decision (keep in mind this was 2014). I came from an MVCS background, so Angular really resonated with me, and it has served us well this entire time. Recently, however, with our improvements to the scheduling graph, we reached a point where performance has become an issue.
Continue reading “Journal: How to embed Vue.js & Vuex inside an AngularJS app… wait what?”

ReactJS vs AngularJS 2 ultimate performance research 2017

  • Note: Among all the Angular 2 features, the availability of MVC pattern out-of-the-box is a significant advantage over React.
  • Having really straightforward UI for your data, Angular allows you to get the end result with the more intuitive approach to the user interface that demands less code and seems to be more ‘obvious’.
  • However, starting from the second version, Angular developers have fixed that issue transferring its rendering model to the server side.
  • As you know, Angular creates a watcher for every binding in order to track all the changes in DOM.
  • We had a little meeting related to React vs Angular question during which our front-end developers had an opportunity to discuss all the pros and cons of these technologies.

These frameworks take top places in our commercial projects. This month, we analyzed their performance and prepared a guideline for web developers in 2017 aimed to help in solving React vs Angular battle.
Continue reading “ReactJS vs AngularJS 2 ultimate performance research 2017”