javascript - How To Access Function From Outside AngularJS -
i have absolutely never used angularjs - able handle parts of else's script - lost newb idea of accessing functions outside of class? or whatever called 0_o - have tried - lost.
the script im working on this:
app.controller("searchformcontroller", function($scope,$http){ $scope.getsomedetails = function(filter){ alert("you doing stuff in function"); } })
the function typically called form outside of script - this:
<select id="transmissions" name="transmission" ng-model="transmission" ng-change="getsomedetails(true)">
when above form element selected - function getsomedetails called properly.
now want call same function text link instead. have tried:
<span onclick="getsomedetails(true)">get details </span>
not sure doing wrong -
i want call same function using text link?
thanks help.
app.controller("searchformcontroller", function($scope,$http){ $scope.getsomedetails = function(filter){ alert("you doing stuff in function"); }; });
here searchformcontroller
angular function.so attached function html template ng-controller
attribute. functions , variable mentioned inside searchformcontroller
available template in have bind function ng-controller
.
your getsomedetails
function in searchformcontroller
. in html template wants call function before needs bind controller it's parent element or element function scope available needs call.
here have call function on click of link use ng-click
. , call function.
your span tag should this.
<span ng-controller="searchformcontroller" ng-click="getsomedetails(true)">get details </span>
Comments
Post a Comment