0

for some reason my input type= "submit" is not working (it's only working for the 1st time). I wrote the input in a custom-control. Will that be a problem? Help is much appreciated. Thanks. Here is my code.

page.zoom = 4;

page.btn_Click = function() {

  if (page.MobileNo) {
    $http.get(serviceBasePath + '/api/Map/GetDeviceLocation?MobileNo=' + page.MobileNo).then(function(response) {

      var deviceindex = page.DeviceData.findIndex(x => x.DeviceId== response.data.DeviceId);
      if (deviceindex == -1) {
        page.DeviceData.push(response.data);
        page.zoom = 14;
        page.center = response.data.Location.position;
      } else {
        page.zoom = 14;
        page.center = response.data.Location.position;
      }

    }, function(error) {})
  }
}
<custom-control style="padding-left:10px; padding-top:10px" position="TOP_LEFT" index="2" on-click="page.btn_Click()">

  <input type="submit" class="form-control" value="GO">

</custom-control>

1 Answers1

0

I think you are missing form tag. try this..

HTML::

<custom-control style="padding-left:10px; padding-top:10px" position="TOP_LEFT" index="2" on-click="page.btn_Click()">
  <form name="formName" onsubmit="submitForm()">
    <input type="text" name="firstName" placeholder="Enter Your Name">
    <input type="submit" class="form-control" value="GO">
  </form>
</custom-control>

Script::

function submitForm(){
  //... do something..
};

if you want some action on ENTER key then you must have some text fields, else on click it will work.

Omprakash Sharma
  • 409
  • 5
  • 11