Skip to content

Instantly share code, notes, and snippets.

@cabrown91
Last active September 16, 2016 22:20
Show Gist options
  • Save cabrown91/02400db5ccfcc8b83ec714e67c0b3532 to your computer and use it in GitHub Desktop.
Save cabrown91/02400db5ccfcc8b83ec714e67c0b3532 to your computer and use it in GitHub Desktop.
Steps to create an Angular project from scratch

Angular Step-By-Step

##Step 1: Angular Set-up Make sure the angular app is plugged in by defining a name for the app in the javascript file, and linking it in the html tag in our html file:

  • app.js
      angular
      .module('appName', []);
  • index.html
    <html lang="en" ng-app="appName">

##Step 2: Create our controllers If we're using a controller, we need to define it in javascript along with our app:

  • app.js
     angular
    .module('appName', [])
    .controller('PageController', PageController);
    
  function PageController () {
  var vm = this;
  vm.newPerson = {};

  vm.newPerson = {
      name: 'Alicia',
      occupation: 'WDI student'
  };
}

##Step 3: Use the controller wherever needed Declare the controller's use in the proper place in our html file:

  • index.html
      <div class="container" ng-controller="PageController as pageCtrl">
            <!--html inside of here can display and adjust the information from the PageController-->
      </div>
@cabrown91
Copy link
Author

cabrown91 commented Sep 16, 2016

<!doctype html>
<html ng-app>
  <head>
    <title>My Angular App</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
  </head>
  <body>
  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment