首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在angular指令中传递字符串

在angular指令中传递字符串
EN

Stack Overflow用户
提问于 2017-06-07 23:04:47
回答 0查看 242关注 0票数 0

我有一个angular指令:

代码语言:javascript
运行
复制
angular.module("App").directive("myButtons", function () {
    return {
        restrict: "E",
        scope: 
            {
                teststring: '@'
            },
        templateUrl: "test.html"
    }
});

使用以下模板:

代码语言:javascript
运行
复制
<div>
    <input type="button" onclick="teststring" value="Hi" />
</div>

这是HTML中的指令:

代码语言:javascript
运行
复制
<my-buttons teststring="Whatsup" />

我希望传递给teststring的值出现在呈现的html中。

目前我只得到了onclick="teststring“。

我做错了什么。我尝试在模板上添加{{ }},并在作用域值上添加@,=和&。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44416369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档