Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何将独立的指令值从指令传递到div_Angularjs - Fatal编程技术网

Angularjs 如何将独立的指令值从指令传递到div

Angularjs 如何将独立的指令值从指令传递到div,angularjs,Angularjs,这里我编写了一个简单的隔离指令,用于显示x和Y值 app.directive('meassageFunction', function () { return { templateUrl: '/Html/IsolatedScope/ISolatedDirective.html', scope: { X: '@', Y:'@' } } }) HtmlPage <div meassage

这里我编写了一个简单的隔离指令,用于显示x和Y值

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值没有分配给你的范围。