Advertisement
Guest User

Untitled

a guest
Jun 6th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. 'use strict';
  2.  
  3. App.controller('CompaniesController', [CompaniesController]);
  4.  
  5. function CompaniesController($scope, $http) {
  6.  
  7. var vm = this;
  8.  
  9. vm.controls = {
  10. form: {
  11. show: false
  12. , button_label: 'Cadastrar'
  13. , button_status: true
  14. , submiting: false
  15. }
  16. };
  17.  
  18. vm.form = {
  19. type_inscription: ''
  20. , inscription: ''
  21. , name: ''
  22. , nick_name: ''
  23. , country: ''
  24. , state: ''
  25. , city: ''
  26. , zipcode: ''
  27. , address: ''
  28. , number: ''
  29. , district: ''
  30. , addition_address: ''
  31. , username: ''
  32. , email: ''
  33. , password: ''
  34. , password_confirm: ''
  35. , language: ''
  36. , timezone: ''
  37. };
  38.  
  39. vm.controlsFormShow = controlsFormShow;
  40. function controlsFormShow() {
  41. vm.controls.form.show = !vm.controls.form.show;
  42. }
  43.  
  44. refresh();
  45. getCountries();
  46.  
  47. vm.refresh = refresh;
  48. function refresh() {
  49.  
  50.  
  51. }
  52.  
  53. vm.add = add;
  54. function add() {
  55. console.log('entrou');
  56. vm.companies.push({name: 'Márcio Dias', email: 'sgeo@sgeo.com.br'});
  57. }
  58.  
  59. vm.remove = remove;
  60. function remove(companies) {
  61.  
  62. }
  63.  
  64. vm.edit = edit;
  65. function edit(company, index) {
  66. vm.controls.form.button = 'Salvar';
  67. }
  68.  
  69. vm.save = save;
  70. function save(company) {
  71.  
  72. }
  73.  
  74. vm.getCountries = getCountries;
  75. function getCountries() {
  76. $http({
  77. method : 'GET',
  78. url : '/api/public/countries',
  79. headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
  80. })
  81. .success(function(data) {
  82. if(data.success == true) {
  83. vm.countries = data.countries;
  84. }
  85. });
  86. }
  87.  
  88. vm.getStates = getStates;
  89. function getStates(value) {
  90.  
  91. if(value !== undefined) {
  92. $http({
  93. method : 'POST',
  94. url : '/api/public/states',
  95. data : { id_country: value },
  96. headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
  97. })
  98. .success(function(data) {
  99. if(data.success == true) {
  100. vm.states = data.states;
  101. }
  102. });
  103. }
  104.  
  105. }
  106.  
  107. vm.getCities = getCities;
  108. function getCities(value) {
  109.  
  110. if(value !== undefined) {
  111. $http({
  112. method : 'POST',
  113. url : '/api/public/cities',
  114. data : { id_state: value },
  115. headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
  116. })
  117. .success(function(data) {
  118. if(data.success == true) {
  119. vm.cities = data.cities;
  120. }
  121. });
  122. }
  123.  
  124. }
  125.  
  126.  
  127.  
  128. }
  129.  
  130. CompaniesController['$inject'] = ['$scope'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement