AngularJS basic file structure to use
app.js
var app = angular.module('mdmApp', ['ngRoute','ngTouch', 'ui.bootstrap','angular-perfect-scrollbar-2']);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
title: 'My Deals',
routeName: 'home',
slideMenu: false,
isSideDisabled: true,
controller: 'NGMyDeals',
templateUrl: 'html/NG-my-deals.html'
})
.when('/advancedSearch/:edit', {
title: 'Advanced Search',
routeName: 'advancedSearch',
slideMenu: true,
isSideDisabled: false,
controller: 'NGAdvanceSearch',
templateUrl: 'html/NG-advance-search.html'
})
.when('/createNewScenario', {
title: '',
routeName: 'createNewScenario',
slideMenu: true,
isSideDisabled: false,
templateUrl: 'html/NG-create-new-scenario.html'
})
.when('/advancedSearchResults', {
title: 'Search Results',
routeName: 'advancedSearchResults',
slideMenu: true,
isSideDisabled: false,
controller: 'NGMyDeals',
templateUrl: 'html/NG-search-results.html'
})
.when('/login', {
title: 'Login As Proxy',
routeName: 'login',
slideMenu: true,
isSideDisabled: false,
templateUrl: 'html/login-as-proxy.html'
})
.when('/saveSearches', {
title: 'Saved Searches',
routeName: 'home',
slideMenu: true,
isSideDisabled: false,
templateUrl: 'html/NG-save-searches.html'
})
.when('/dealPricing', {
title: 'Deal Pricing',
routeName: 'dealPricing',
slideMenu: true,
isSideDisabled: false,
templateUrl: 'html/NG-deal-pricing.html'
})
.when('/components', {
title: 'Components',
routeName: 'components',
slideMenu: false,
isSideDisabled: false,
templateUrl: 'html/components.html'
})
.otherwise({
redirectTo: '/'
});
});
-----------------------------------
controllers.js
app.controller('MainController', function ($scope, $http, $location, $modal) {
$scope.slideMenu = function () {
$scope.slideMenuActive = !$scope.slideMenuActive;
};
$scope.radioModel='LPL';
$scope.openChangeAccess = function (size) {
var modalInstance = $modal.open({
animation : 'true',
templateUrl : 'templates/common/changeAccess.html',
controller: 'ModalInstanceCtrl',
size : 'md'
});
};
$scope.openAddProxy = function (size) {
var modalInstance = $modal.open({
animation : 'true',
templateUrl : 'templates/common/addProxy.html',
controller: 'ModalInstanceCtrl',
size : 'lg'
});
};
$scope.openQuickLinks = function (size) {
var modalInstance = $modal.open({
animation : 'true',
templateUrl : 'templates/common/quickLinks.html',
controller: 'ModalInstanceCtrl',
size : 'lg'
});
};
$scope.openDeleteRow = function (size) {
var modalInstance = $modal.open({
animation : 'true',
templateUrl : 'templates/common/deletePopup.html',
controller : 'ModalInstanceCtrl',
size : 'sm'
});
};
$scope.openAppReq = function (size) {
var modalInstance = $modal.open({
animation : 'true',
templateUrl : 'templates/myDeals/appRequired.html',
controller : 'ModalInstanceCtrl',
size : 'lg'
});
};
$scope.go = function ( path ) {
$location.path( path );
};
$scope.typeAhead = ['Mary Williams (marywill)'];
$scope.scrollopts = {
wheelSpeed: 1,
wheelPropagation: true,
minScrollbarLength: 20
};
});
-------------------------------------------
directives.js
app.directive('toggleClass', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
element.toggleClass(attrs.toggleClass);
});
}
};
});
app.directive('selectBox', function($timeout) {
return {
restrict: 'E',
replace: true,
scope: {
selected: '=',
array: '=',
class: '='
},
template: '',
controller: ['$scope', function($scope) {
$scope.changeVal = function(v){
$scope.array[0].selectedValue = v;
}
}]
};
});
0 comments :
Feel free to leave comment if you like above widget, have any questions or just say Hi! :)