我的情况如下:
指示
scope: { foo:'=' },
template: '<input type="checkbox" ng-model="foo"/>'
Run Code Online (Sandbox Code Playgroud)
父控制器
$scope.foo = false;
Run Code Online (Sandbox Code Playgroud)
茉莉花试验
var cb = iElement.find('input');
$timeout(function() { // using $timeout to ensure $digest() isn't the issue.
cb.prop('checked',!cb.prop('checked'))
},0);
expect(cb.prop('checked')).toBe(true); // passes
expect($scope.foo).toBe(true); // doesn't pass
Run Code Online (Sandbox Code Playgroud)
我的问题:为什么$ scope.foo在我发出prop('checked')时不会更新,即使DOM确实如此(因为我在检查之后已经验证了).
这是一个jsbin大致演示了问题http://jsbin.com/kapifezi/2/edit
Vs 代码 > 输出 > 更漂亮
2/23/2020, 12:10:36 PM:
-----------------------
Expression expected. (/Users/yanivper/dev/test/test.ts:2:23)
1 | function test(obj) {
2 | return obj.a?.b;
^
Run Code Online (Sandbox Code Playgroud)
在一个新项目中:
npm i typescript
Run Code Online (Sandbox Code Playgroud)
VScode 使用 Workstation Version 3.8.2(显示在左下栏 TypeScript 3.8.2 ) Prettier v 2.2.2