Angularjs 如何将独立的指令值从指令传递到div
这里我编写了一个简单的隔离指令,用于显示x和Y值Angularjs 如何将独立的指令值从指令传递到div,angularjs,Angularjs,这里我编写了一个简单的隔离指令,用于显示x和Y值 app.directive('meassageFunction', function () { return { templateUrl: '/Html/IsolatedScope/ISolatedDirective.html', scope: { X: '@', Y:'@' } } }) HtmlPage <div meassage
app.directive('meassageFunction', function () {
return {
templateUrl: '/Html/IsolatedScope/ISolatedDirective.html',
scope: {
X: '@',
Y:'@'
}
}
})
HtmlPage
<div meassage-function X="Md" , Y="Ghouse">
</div>
你的工作中有很多打字错误,干扰了你的工作 请注意,范围变量区分大小写(x与x不同),使用您定义的指令非常重要
angular.module('thing',[]).directive('messageFunction',function(){
返回{
模板:{{x}}{{y}},
范围:{
x:“@”,
y:“@”
}
}
})
指令中的x
和y
属性之间不需要逗号。此外,您正在调用指令“隔离函数”,但您已经定义了“消息函数”,其中甚至没有use@JHECT你现在可以验证一下吗?请检查我的答案。好的@Jhecht tq soo muchweni尝试一下{{x}}{{y}为什么x和y值没有分配给你的范围。