相关疑难解决方法(0)

AngularJS ng-if和范围

我试图了解ng-if和范围.据我所知,ng-if创建了一个新的子范围.这是我的问题:

视图

<input ng-model="someValue1" />
<div ng-if="!someCondition">
    <input ng-model="$parent.someValue2" />
</div>
Run Code Online (Sandbox Code Playgroud)

调节器

$scope.someCondition = true;

if ($scope.someCondition) {
    $scope.someValue2 = $scope.someValue1;        
}
Run Code Online (Sandbox Code Playgroud)

如果someCondition设置为true,则someValue2应与someValue1相同.

我的问题是我无法在两种情况下访问someValue2(true或false).我怎么能实现这个目标?

angularjs angular-ng-if

19
推荐指数
3
解决办法
3万
查看次数

标签 统计

angular-ng-if ×1

angularjs ×1