I am able to submit function from another javascript function but submit angularjs function is executed after javascript function is completed.