假设我有一个复选框指令,我正在从 angularjs 重写为 angular
checkbox.directive.js (angularjs)
template: `<some html> ...`,
scope: { checked: '=', onChecked: '&' }
checkbox.component.ts(角度)
@Component({
selector: 'checkbox',
templateUrl: '<some html> ...',
...
})
export class CheckboxComponent implements OnInit {
@Input() checked: boolean;
@Output() checkedChange = new EventEmitter<boolean>();
@Output() onCheckedChange = new EventEmitter<boolean>();
...
如何从尚未升级的组件绑定到表达式绑定 (&)?
尚未升级的.directive.js (angularjs)
template: '<checkbox (onChecked)="foo()"> ...',
controller: function($scope) {
$scope.foo = function() { console.log("change happened"); }
}