Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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 使用vm而不是$scope_Angularjs - Fatal编程技术网

Angularjs 使用vm而不是$scope

Angularjs 使用vm而不是$scope,angularjs,Angularjs,我尝试使用虚拟机。但有时它起作用,但有时不起作用 这是我的密码: <div ng-controller="ProfileCtrl as profile"> <div class="profile-box"> <h4 class="m-b-0">{{ profile.name }}</h4> <p class="text-muted"> {{profile.username }}</p>

我尝试使用虚拟机。但有时它起作用,但有时不起作用

这是我的密码:

<div ng-controller="ProfileCtrl as profile">
   <div class="profile-box">
        <h4 class="m-b-0">{{ profile.name }}</h4>
        <p class="text-muted"> {{profile.username }}</p>
   </div>
</div>
如何使用虚拟机使其正常工作


谢谢。

我认为关键是:

vm.profile = resp.user;
在您看来,正确的参考方法是:

{{profile.profile.name}}

第一个概要文件引用ProfileCtrl中的控制器作为概要文件,第二个概要文件引用vm.profile=resp.user中该控制器中的概要文件对象

我认为关键在于:

vm.profile = resp.user;
在您看来,正确的参考方法是:

{{profile.profile.name}}
第一个概要文件引用ProfileCtrl中的控制器作为概要文件,第二个概要文件引用vm.profile=resp.user中该控制器中的概要文件对象

更改为在视图中使用它,如vm.profile.prop

更改为在视图中使用它,如vm.profile.prop