1
我試圖遷移我的角1個指令角2.這是我簡單的角1個指令如何使用角1指示在角2
extCheckbox.html
<input type=checkbox
name ="{{checkboxName}}"
id="{{checkboxId}}"
data-ng-readonly="isReadonly"
data-ng-checked="isChecked"/>
這是我的指令extCheckbox.js
var app = angular.module('Demo');
app.directive('extCheckbox', [function() {
return {
restrict: 'E',
scope: {
label: '@',
name: '@',
id: '@',
isDisabled: '=?',
isReadonly: '=?',
isChecked: '=?',
},
templateUrl: './extCheckbox.html',
replace: true,
transclude: false,
link: function (scope, element, attrs) {
if (attrs.isChecked === undefined) {
scope.isChecked =true;
}
}
};
}]);
我遷移這角2如下,
個extCheckbox.Component.ts
import {Component} from '@angular/core';
import {UpgradeAdapter} from '@angular/upgrade';
const upgradeAdapter = new UpgradeAdapter();
let ExtCheckbox = upgradeAdapter.upgradeNg1Component('ext-Checkbox');
@Component({
selector: 'ext-mycheckbox',
template: '<ext-checkbox></ext-checkbox>',
directives: [ExtCheckbox]
})
export class checkboxComponent{
}
app.components.ts
import {Component} from '@angular/core';
import {checkboxComponent} from './extCheckbox.Component';
@Component({
selector: 'my-app',
template: '<h1>checkboxComponent</h1><ext-mycheckbox></ext-mycheckbox>',
directives:[checkboxComponent]
})
export class AppComponent {
}
的選擇我的應用程序內元素已在我的index.html被賦予但複選框不會顯示在我的頁面中。