'use strict';

angular.module('test', ['simpleForm']);

angular.module('test')

.controller('TestCtrl', ['$scope', function($scope) {
  $scope.success = true;
  $scope.$watch('success', function() {
    $scope.submit.url = $scope.success ? 'http://demo5712530.mockable.io/success' : 'http://demo5712530.mockable.io/error';
  });

  $scope.name = 'sample';

  $scope.submit = {
    label: 'Send Data',
    error: 'Error!',
    method: 'POST',
    url: 'http://demo5712530.mockable.io/success',
    headers: {},
    callback: {
      success: function() {
        alert('success');
      },
      error: function() {
        alert('error');
      }
    }
  };

  $scope.inputs = [
    {
      name: 'name',
      type: 'text',
      label: 'Name:',
      placeholder: 'Miyuki',
      required: true,
      errMsgs: {
        required: 'Name is required.'
      },
      pattern: ''
    },
    {
      name: 'email',
      type: 'email',
      label: 'Email:',
      placeholder: 'miyuki@test.com',
      required: true,
      errMsgs: {
        required: 'Email is required.',
        email: 'Invalid email.'
      },
      pattern: '',
      confirm: true
    },
    {
      name: 'password',
      type: 'password',
      label: 'Password:',
      placeholder: '',
      required: true,
      errMsgs: {
        required: 'Password is required.',
        pattern: 'Invalid pattern.'
      },
      pattern: /^[ -~]{8,}$/,
    }
  ];
}]);
@@ -127,16 +127,146 @@
 cope) %7B%0A
+  var mockURLs = %7B%0A    success: 'http://demo5712530.mockable.io/success',%0A    error: 'http://demo5712530.mockable.io/error'%0A  %7D;%0A%0A
   $scope
@@ -367,89 +367,41 @@
 s ? 
-'http://demo5712530.mockable.io/
+mockURLs.
 success
-'
  : 
-'http://demo5712530.mockable.io/
+mockURLs.
 error
-'
 ;%0A  
@@ -530,48 +530,24 @@
 rl: 
-'http://demo5712530.mockable.io/
+mockURLs.
 success
-'
 ,%0A  

Modify mock URLs