使用ng-click Angularjs调用多个方法

时间:2015-09-03 09:01:08

标签: javascript angularjs ionic-framework ionic

语法如何在ng-click控件中调用两个方法。

HTML

ng-click="submitForm(M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15), postComments(comment)">

我用逗号尝试了它,没有一个。

错误

Error: [$parse:syntax] Syntax Error: Token ',' is an unexpected token at column 77 of the expression [submitForm(M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15), postComments(comment)] starting at [, postComments(comment)].
http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%2C&p1=is%20an%20unexpected%20token&p2=77&p3=submitForm(M1%2C%20M2%2C%20M3%2C%20M4%2C%20M5%2C%20M6%2C%20M7%2C%20M8%2C%20M9%2C%20M10%2C%20M11%2C%20M12%2C%20M13%2C%20M14%2C%20M15)%2C%20postComments(comment)&p4=%2C%20postComments(comment)
    at REGEX_STRING_REGEXP (http://localhost:8100/lib/ionic/js/ionic.bundle.js:8895:12)
    at Object.AST.throwError (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21708:11)
    at Object.AST.ast (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21478:12)
    at Object.ASTCompiler.compile (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21927:31)
    at Parser.parse (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22776:29)
    at $parse (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22900:39)
    at http://localhost:8100/lib/ionic/js/ionic.bundle.js:57510:7
    at IonicModule.config.factory.directive.directive.restrict (http://localhost:8100/lib/ionic/js/ionic.bundle.js:57526:5)
    at invokeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17477:9)
    at nodeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:16977:11) <ion-item class="item-balanced item item-complex" href="#/app/checklist" value="submit" ng-click="submitForm(M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15), postComments(comment)">

1 个答案:

答案 0 :(得分:2)

您需要在函数调用之间放置;(分号),而不是,(逗号)

ng-click="submitForm(M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15); postComments(comment)">