Flask by Example

  • Grab the id and navigate to this url:

    You should see a similar JSON response in your browser:

    Now we’re ready to add in Angular.

  • Be sure to add the requirement to the index.html file:

    Here, when the form is submitted, is called, which simply logs the text “test” to the JavaScript console in the browser.

  • Instead, we’ll use the Angular service to handle this request asynchronously:

    Also, update the element in index.html:

    We injected the service, grabbed the URL from the input box (via ), and then issued a POST request to the back-end.

  • Refactor out the Redis job creation from the index view function, and then add it to a new view function called :

    Make sure to add the following import at the top as well:

    These changes should be straightforward.

  • Update main.js by adding the following code to the controller:

    Then update the success handler in the POST request:

    Make sure to inject the service into the controller as well.

This tutorial details how to utilize to create a polling service with Angular.
Continue reading “Flask by Example”

Why Vue 2 beats Angular 2 and React – Jon Paul Miles – Medium

  • At first it was going to be Angular 2 vs React, but then a friend mentioned that people who used Vue wished they had known about it sooner and preferred it over React.I built a small dynamic single page in a single app in Vue 2, Angular, and React and I measured things like learning time, difficulty, and boilerplate.
  • The boiler plate was less than Angular 2 and less than React.
  • Vue also had directives which allowed my users to maintain their theme api.Vue is more like Angular 1 than Angular 2 is (without Dependency Injection) and it’s faster than even React.Vue 2 combines the best parts of React, and Angular 1 2.
  • Keep in mind when I said Angular 2 took I week, I meant just the initial learning not mastery.ConclusionFor any new web app, I will almost certainly recommend Vue 2 over React or Angular 2.
  • Members of your team can learn and master it faster, the framework runs faster than the other two, the boiler plate is the least exhausting, and it provides the best capabilities of React and Angular 1 2.

We started a contest at my job to see which framework was the best. At first it was going to be Angular 2 vs React, but then a friend mentioned that people who used Vue wished they had known about it…
Continue reading “Why Vue 2 beats Angular 2 and React – Jon Paul Miles – Medium”

javascript

  • My question involves how to go about dealing with complex nesting of templates (also called partials) in an AngularJS application.
  • Here is an example of what’s in my app:

    In circle 2, the template that is loaded into the has an additional sub-navigation.

  • I know that I can include additional templates within the 1st template, but these templates are all going to be pretty complex.
  • I would like to keep all the templates separate in order to make the application easier to update and not have a dependency on the parent template having to be loaded in order to access its children.
  • There is the potential that the sub-navigation templates will have a 2nd sub-navigation that will need to load its own templates as well into the area in circle 4

    How does one go about structuring an AngularJS app to deal with such complex nesting of templates while keeping them all separate from one another?

My question involves how to go about dealing with complex nesting of templates (also called partials) in an AngularJS application.
Continue reading “javascript”

Automate JavaScript workflow with Gulp

  • Minifiction, concatenation, browser refresh, server restart etc are some of the tasks that Gulp can take care for us.
  • Gulp allows us to pipe the output of one plugin as an input to another, hence allowing us to use multiple plugins in single tasks.
  • For Example – In gulp we can minify and concat in one tasks and write the final output, on the other hand in Grunt we will have to write the out put of one plugin first and then take it as an input for another plugin and write the final output.
  • Using Gulp tasks (gulp.task) we can use Gulp plugins to perform the desired operation on the source files and then pipe them into the destination folder.
  • allows us to watch files for changes and run other gulp tasks whenever those files are changed.

Gulp will automate the workflow for your JavaScript projects. Gulp lets us perform tasks like minification, jslint, sass compilation etc.
Continue reading “Automate JavaScript workflow with Gulp”

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”

Active Voice

unit testing - Angular News  #angularjs #reactjs

  • I want to Test the above method that has a dependency on the AutoMapper.
  • Below is the code from Test Method.
  • I do get back the correct Count but objects are all Null.
  • I tried using Returns, but than it only returns one object.
  • I do get back the correct Count but objects are all ; Continue reading ;unit testing;

I want to Test the above method that has a dependency on the AutoMapper. Below is the code from Test Method. I do get back the correct Count but objects are all Null. I tried using Returns, but than it only returns one object. I do get back the correct Count but objects are all ; Continue reading ;unit testing;
Continue reading “Active Voice”

unit testing

AutoMapper Test for IQueryable Mapping  #angularjs #reactjs

  • I want to Test the above method that has a dependency on the AutoMapper.
  • Below is the code from Test Method.
  • I do get back the correct Count but objects are all Null.
  • I tried using Returns, but than it only returns one object.

I do get back the correct Count but objects are all Null. I tried using Returns, but than it only returns one object.
Is it possible to Return the collection ?
Continue reading “unit testing”