【发布时间】:2021-12-19 02:16:06
【问题描述】:
目前,我知道如何从文本框中收集输入并将其用于$scope 变量。但是如果我不想使用$scope 变量怎么办?如果我只是想将输入作为参数传递给函数怎么办?
目前:
我有一些看起来像这样的 JSP:
<textarea
required="true"
spellcheck="on"
data-ng-model="editTools.productDescription"
rows="4"
>
</textarea>
我在 JSP 中也有一个按钮,它调用 Angular JS 中的函数:
<button
id="description-submit-button"
data-ng-click="mySpecialFunction()"
buttonType="${'primary'}"
htmlButtonType="${'button'}"
>
<text>"Submit"</text>
</button>
所以,我知道这是可行的。我正在为$scope.editTools.productDescription 分配一个值,然后mySpecialFunction() 使用该值。
但是如果不使用$scope 变量,我将如何完成同样的事情呢?我希望能够说类似data-ng-click="mySpecialFunction({the stuff the user typed in the text box})"
这可能吗?怎么样?
【问题讨论】:
标签: javascript html angularjs jsp