Basic Angular File Structure for Most Applications

08:23:00 0 Comments




Hey Guys here I am sharing with you the Very basic file structure to start writing any Angular Js application...I hope it is useful in your projects

It consists of two main files

the html file and the js file


The HTML file will look like the following

<html ng-app="joealmodule" ng-controller="JoelController">
<head>
/*scripts to include jquery and angular and css*/
<link rel="stylesheet" type="text/css" href="style.css">

        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="js/angular.min.js"></script>
    <script src="js/angular-animate.js"></script>
    <script src="js/pagination.js"></script>
    <script src="js/toastr/angular-toastr.min.js"></script>
    <script src="js/toastr/angular-toastr.tpls.min.js"></script>

    <script src="js/admin.js"></script>
</head>
<body>
</body>
<html>

Now here below you will see the admin.js file

var joelmodule = angular.module("joelmodule",["toastr","angularUtils.directives.dirPagination"]);
joelmodule.controller("JoelController", function($scope,$http, toastr,$timeout) {
     
toastr.success('Hello world!', 'Toastr fun!');

/*define functions*/
$scope.myfunctionname = function (){
alert('my first function');
}

});


joelmodule.config(function(paginationTemplateProvider) {
    
    setTimeout(function(){ paginationTemplateProvider.setPath('dirPagination.tpl.html'); }, 3000);
    
});


Here is the full explanation for pagination 
https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination

View his Video for full understanding




Apart from this I have even added Toaster for messages


Make sure to download the files in the correct location ie dirPagination.tpl.html should be placed in the same folder as the html file as per the above example..Comment below if you still have doubts..

I hope that this tutorial was useful to you...


Joel

Joel Fernandes,I am a Very Smart,Innovative Creative and One of the Best Webdevelopers.I am an expert in Webdevelopment.My other interest include Cars and Vehicles.My desire is to be the best and serve you with the best information I have .I will always share all my tips and tricks on this website and provide you with the best themes so that your life may be simpler.Keep visiting www.joelwebsites.com for the best website related ,tips and tricks and news.Meet me on FaceBook

0 comments: