-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagregarCtrl.template
40 lines (36 loc) · 1.12 KB
/
agregarCtrl.template
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
'use strict';
/**
* @ngdoc function
* @name nameApp.controller:Agregar{{entity.name|capitalize}}Ctrl
* @description
* # Agregar{{entity.name|capitalize}}Ctrl
* Controller of the nameApp
*/
angular.module('nameApp')
.controller('Agregar{{entity.name|capitalize}}Ctrl', function ($scope, $http) {
$scope.title = '{{entity.name|capitalize}}';
$scope.message = 'Agregar {{entity.name|capitalize}}';
{% for property in entity.properties %}
$http.get(api_path + '{{property.name}}?limit=0')
.then(function(response) {
$scope.{{property.name}} = response.data;
});
{% endfor %}
$scope.add = function(){
{% for property in entity.properties %}
if($scope.{{entity.name}}.{{property.name}} == null){
return;
}
{% endfor %}
var data = {
{% for property in entity.properties %}
{{property.name}}: $scope.{{entity.name}}.{{property.name}},
{% endfor %}
};
$http.post(api_path + '{{entity.name}}',data);
window.location.href = '#/{{entity.name}}';
};
$scope.cancel = function(){
window.location.href = '#/{{entity.name}}';
};
});