samedi 27 juin 2015

Why I can't pass angularJS paramater on onClick html event?

I'm trying to concat a string with a AngularJS expression in html. See the example above:

angular.module("app", []);
function MyCtrl($scope){
    $scope.item = "Hello";
    $scope.say = function(text){
        alert(text);
    };
}
<script src="http://ift.tt/1oMJErh"></script>
<script src="http://ift.tt/1mQ03rn"></script>
<script>
    function openFunctionJS(param){
        alert(param);
    };
</script>
<div ng-app="app" ng-controller="MyCtrl">
    <a ng-click="say(item + ' World')">Say {{item}} World by ngclick</a><br/>
    <a onclick="openFunctionJS('{{item}}')">Say {{item}} World by onclick</a>
</div>

http://ift.tt/1GIE7rR

But it doesn't work. My entire function is in JavaScript and I don't want to change it right now if possible.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire