DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Frameworks
  4. How to Write AngularJS Frontends for LoopBack Applications

How to Write AngularJS Frontends for LoopBack Applications

Niklas Heidloff provides an example of how to write AngularJS front-end against the Loopback Node.js API framework.

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
Mar. 03, 16 · Tutorial
Like (2)
Save
Tweet
Share
10.08K Views

Join the DZone community and get the full member experience.

Join For Free

with the node.js api framework loopback you can easily provide rest apis for your applications. in order to build web frontends, loopback provides an angularjs javascript sdk . below is a sample application which demonstrates how to use this sdk.

download the sample application from github.

in angularjs applications, you typically build views that interact with services via controllers. the services access data from the server-side applications. obviously, you can write your own services which invoke the rest apis of your loopback applications directly. but, loopback makes this even simpler via the angularjs sdk. with the sdk, client-side javascript libraries are generated for your rest apis so that the controllers can simply invoke javascript apis rather than rest apis.

the sample application demonstrates how to build a web-based frontend for a simple approval request scenario. approval requests have titles, descriptions, requesters, and approvers.

angular-5s

here is the code snippet of the controller that returns all approval requests. the class approvalrequest is provided by the loopback sdk.

angular.module('angularapp').controller('requestscontroller', ['$scope', 'approvalrequest', function($scope, approvalrequest) {
  $scope.requests = [];
  function getrequests() {
      approvalrequest.find().$promise
        .then(function(results) {
          $scope.requests = results;
        }, 
        function(err) {
          $scope.requestserror = err.statustext;
        }
    );
  }
  getrequests();
}]);

authentication is also very easy from angular. just invoke the person.login function.

the file lb-services.js with the javascript apis for your own business objects defined via loopback is generated either via command line or via grunt . the approval request sample application uses the grunt plugin to build the file automatically and to put it in the angular application.

application AngularJS

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 19 Most Common OpenSSL Commands for 2023
  • Host Hack Attempt Detection Using ELK
  • How To Best Use Java Records as DTOs in Spring Boot 3
  • How to Use Buildpacks to Build Java Containers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: