-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
76 lines (65 loc) · 2.67 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
define([
], function () {
var app = angular.module("app", ['ngRoute','ngAnimate','LocalStorageModule','angular-growl']);
app.config(['$routeProvider','$locationProvider','$httpProvider', function($routeProvider,$locationProvider,$httpProvider){
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
$routeProvider.when('/:params',
{
template : '<div data-ng-controller="controller" id="view"></div>',
controller : 'DynamicController'
}
).when('/:params/:actions',
{
template : '<div data-ng-controller="controller" id="view"></div>',
controller : 'DynamicController'
}
).otherwise({ redirectTo: 'beranda' });
$locationProvider.hashPrefix("!");
}]);
app.controller('DynamicController', function ($scope, $routeParams, $compile) {
$scope.actions = $routeParams['actions'];
$scope.controller = function(){};
require([
'./core/controller/ctrl.' + $routeParams['params'],
'text!./core/view/' + $routeParams['params'] + '.html'
], function(controller, view){
$scope.controller = controller;
var v = angular.element("#view").html(view);
$compile(v)(v.scope());
$scope.$apply();
}
);
});
app.filter('toHTML', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
});
app.controller('CtrlHeader', function ($scope,localStorageService,$window,$location) {
var tblC = localStorage.getItem("todos");
tblC = JSON.parse(tblC);
if(tblC == null) {
$scope.todos = [];
} else {
$scope.todos = tblC;
}
$scope.remaining = function() {
var count = 0;
angular.forEach($scope.todos, function(todo){
count+= todo.done ? 0 : 1;
});
return count;
};
$scope.logout = function(){
localStorageService.clearAll();
localStorage.removeItem('todos');
$window.localStorage.clear();
$location.path('/');
}
});
// app.baseUrlServer = 'http://localhost/melamar/knitto/server/';
app.baseUrlServer = 'http://35.229.83.128/server/';
return app;
});