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 角度1.5+;承诺返回的值上的嵌套组件绑定_Angularjs - Fatal编程技术网

Angularjs 角度1.5+;承诺返回的值上的嵌套组件绑定

Angularjs 角度1.5+;承诺返回的值上的嵌套组件绑定,angularjs,Angularjs,我目前正在学习AngularJS组件。我想在父组件和子组件之间绑定一个值,知道父组件中的值是由RESTful服务返回的: parent.template.html <h3>{{$ctrl.hero.name}}</h3> <child hero="$ctrl.hero"></child> <div>{{$ctrl.hero.name}}</div> child.template.html <h3>{{$ctr

我目前正在学习AngularJS组件。我想在父组件和子组件之间绑定一个值,知道父组件中的值是由RESTful服务返回的:

parent.template.html

<h3>{{$ctrl.hero.name}}</h3>
<child hero="$ctrl.hero"></child>
<div>{{$ctrl.hero.name}}</div>
child.template.html

<h3>{{$ctrl.hero.name}}</h3>
<child hero="$ctrl.hero"></child>
<div>{{$ctrl.hero.name}}</div>
我假设子组件无法从父组件获取“hero”,因为$promise返回了“hero”

你有没有办法像这样绑定值

提前感谢您的帮助

问候,,
Leona

在这种情况下,这是一个简单的打字错误-应该是
bindings
而不是
bingdings
。作为旁注,在这种特殊情况下,使用从1.5版开始提供的所谓:

.component('child', {
  templateUrl:'child/child.template.html',
  controller: childController,
  bindings: {
    hero: '<'
  },
  transclude:true
});
.component('child'{
templateUrl:'child/child.template.html',
控制器:childController,
绑定:{

英雄:'@raina77ow我会给你一个正确的答案!…这是由于“bindings”的拼写错误造成的…感谢…将来会看到这篇文章的用户:我们可以像往常一样绑定$promise返回的值。如果不能,请仔细检查拼写。。。