Giter Site home page Giter Site logo

angularjs-codeql-poc's Introduction

Baasic AngularJS Article Module Hello World

In order to create a hello world sample based on the Baasic article module you should follow the steps described below:

Prerequisites

Sign up for Baasic account

Head over to Baasic registration form and fill in the required fields to create an account. You will receive an activation e-mail to confirm your registration, after confirmation please navigate to your account dashboard and follow the next step.

Create your application

Account dashboard allows you to manage all of your Baasic applications in one place. To create new application click the Add a New App on the account dashboard and enter the application name and administrator's account information.

Write your hello world article

Navigate to the application dashboard https://dashboard.baasic.com/apps/your-api-key/ and use compose article (https://dashboard.baasic.com/apps/your-api-key/article/add) screen to add hello world article that we will use in the AngularJS application.

Create AngularJS application

Create an AngularJS application by using the following code:

    angular.module('baasicArticleHelloWorld', [
        "baasic.api",
        "baasic.article"
    ])

Note that we will be using only Baasic AngularJS Core and Article SDK to build the hello world application, so you may notice that there are two dependencies defined baasic.api and baasic.article that we need for this app.

Configure the Baasic application

In order to configure Baasic application we will need a baasicAppProvider injected in the AngularJS application configuration, to do that use the following:

   angular.module('baasicArticleHelloWorld').config(['baasicAppProvider',
        function (baasicAppProvider) {

            baasicAppProvider.create('Article-Hello-World', {
                apiRootUrl: 'api.baasic.com',
                apiVersion: 'beta'
            });

    }])

Create Hello World Controller

To fetch the hello world article that we have wrote using the Baasic article dashboard we will need simple controller that will fetch the articles from the Baasic back-end. To do that we will use the following code:

     angular.module('baasicArticleHelloWorld').controller('MainController', ['$scope', 'baasicArticleService',
        function($scope, articleService) {
            $scope.articles = [];

            var apiParams = {
                embed: "Tags",
                statuses: 'published'
            };
            articleService.find(apiParams)
                .success(function (collection) {
                    $scope.articles = collection.item;
                });
        }]);

Create Hello World Index.html

To actually display the articles from the back-end we need a mark-up and for this purpose we will use HTML5 with our AngularJS application. Create index.html and use the following mark-up to display the articles:

<!DOCTYPE html>
<html ng-app="baasicArticleHelloWorld">
  <head>
    <meta charset="utf-8"/>
    <title>Baasic AngularJS Article Hello World</title>
  </head>
  <body>
    <h1>Baasic AngularJS Article Hello World</h1>
    <div ng-controller="MainController">
        <div ng-repeat="article in articles">
            <h2>{{article.title}}</h2>
            <p>{{article.content}}</p>
        </div>
        <div ng-show="articles.length === 0">
            <p>No articles in the application.</p>
        </div>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <script src="http://cdn.baasic.com/angularjs/baasic-javascript-framework-1.0.0.min.js"></script>
    <script src="http://cdn.baasic.com/angularjs/uritemplate-1.0.0.min.js"></script>
    <script src="http://cdn.baasic.com/angularjs/angular-hal-parser-1.0.0.js"></script>
    <script src="http://cdn.baasic.com/angularjs/baasic-angular-core-1.0.0.min.js"></script>
    <script src="http://cdn.baasic.com/angularjs/baasic-angular-article-1.0.0.min.js"></script>

    <script src="app.js"></script>
  </body>
</html>

Dependencies for this applications, as mentioned earlier, are only Baasic AngularJS Core and Article SDK and you can use the Baasic CDN to serve the SDKs.

Source code

Full source code can be found on the GitHub. More information about the Demo can be found in the blog post here.

How to Run

Well, you just need to open a index.html file from the src folder and thats it.

Get in touch

Get in touch using one of the community channels

GitHub: Baasic Google Groups: Baasic Support Twitter: @baasical

angularjs-codeql-poc's People

Contributors

khorvat avatar vibhorchhabra321 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.