在本文中,我们将给您介绍关于angular–禁用表单打字稿中的所有控件的详细内容,并且为您解答angular按钮禁用的相关问题,此外,我们还将为您提供关于Android动态清空LinearLayout
在本文中,我们将给您介绍关于angular – 禁用表单打字稿中的所有控件的详细内容,并且为您解答angular按钮禁用的相关问题,此外,我们还将为您提供关于Android 动态清空LinearLayout中的所有控件、Angular 12.1 使用打字稿添加 html 元素、Angular 2 – 导入外部传单打字稿库、Angular 2打字稿到javascript?的知识。
本文目录一览:- angular – 禁用表单打字稿中的所有控件(angular按钮禁用)
- Android 动态清空LinearLayout中的所有控件
- Angular 12.1 使用打字稿添加 html 元素
- Angular 2 – 导入外部传单打字稿库
- Angular 2打字稿到javascript?
angular – 禁用表单打字稿中的所有控件(angular按钮禁用)
试过的解决方案.
使用fieldset并将[disabled]设置为 – 这在IE 9中不起作用.
同样使用fieldset,不会禁用输入
<buttontype="button" title="Add New " data-toggle="modal" id="Btn" data-backdrop="false"><i (click)="Person(Code)"></i></button> <p-radioButton name="type" value="I" label="Inc" [(ngModel)]="type"></p-radioButton>
我没有表单组,因此该解决方案在这里也不起作用.
让我知道AngularJS 2中是否还有其他解决方案
解决方法
Android 动态清空LinearLayout中的所有控件
private List<LinearLayout> linearLayoutList = new ArrayList<>();
if (linearLayoutList.size() > 0) {
for (LinearLayout linearLayout : linearLayoutList) {
//清空布局
linearLayout.removeAllViews();
}
linearLayoutList.clear();
}
Angular 12.1 使用打字稿添加 html 元素
如何解决Angular 12.1 使用打字稿添加 html 元素?
我正在通过 youtube 学习 angular,但我正在尝试做一些新的事情,我遇到了一个错误,我的代码附在下面,帮帮我。
我想像这样设置属性 div.setAttribute(''(click)'',"popUp($event)");
但我出错了。
打字稿
export class AppComponent {
createEl(){
console.time("timer");
for (let i = 0; i < 10; i++) {
let div = document.createElement("div");
div.textContent = `Hello,World! ${i}`;
div.setAttribute(''(click)'',"popUp($event)");
document.getElementById(''divel'')?.appendChild(div);
};
console.timeEnd("timer");
}
HTML
<div id="divel"></div>
<button (click)="createEl()">click me</button>
错误
解决方法
您可以如下设置点击事件,而不是使用 setAttribute
div.addEventListener(''click'',(e) => {
this.popUp(e);
});
,
这并不是真正的有角的做事方式。尽量避免对 document.createElement
等文档进行操作。
实现这一点的更好方法是定义模板中重复元素的外观并从数组中驱动它。这样我们就可以让模板做显示,打字稿做处理,Angular 处理两者之间的一切。
HTML
<div id="divEl">
<div *ngFor="let row of rows; index as i;" (click)="popUp($event)">
Hello,World! {{i}}
</div>
</div>
<button (click)="createEl()">click me</button>
打字稿
export class AppComponent {
rows: unknown[] = [];
createEl():void {
this.rows.push(''something'');
}
popUp(event:Event):void {}
}
更多关于循环的阅读:https://angular.io/api/common/NgForOf
,这是正确的检查。
div.addEventListener(''click'',(e) => {
this.popUp(e);
});
,
(click)
不是 html 属性,它是 Angular event binding syntax
此语法由等号左侧括号内的目标事件名称和右侧带引号的模板语句组成。
您不能在 JavaScript 中使用它。使用
div.onclick = popUp;
Angular 2 – 导入外部传单打字稿库
这是我的地图组件.我用tsd install安装了leaflet.d.ts,我的应用程序没有抱怨///< reference path =“../../ typings / leaflet / leaflet.d.ts”/>但是当我尝试使用L.map,它是leaflet.d.ts中的导出模块时,我得到错误“ReferenceError:L未定义”.这是我第一次尝试在角度2中导入外部打字稿库,显然我做错了.
/// <reference path="../../typings/leaflet/leaflet.d.ts"/> import { Component } from 'angular2/core'; @Component({ selector: 'map',template: ` <div id="map"></div> `,}) export class Map{ constructor(){ var map = new L.Map('map',{ zoomControl: false }); }
的package.json
{ "dependencies": { "angular2": "^2.0.0-beta.3","es6-promise": "^3.0.2","es6-shim": "^0.33.3","normalize.css": "^3.0.3","reflect-Metadata": "0.1.2","rxjs": "5.0.0-beta.2","systemjs": "0.19.6","typings": "^0.6.4","zone.js": "^0.5.11" },"devDependencies": { "concurrently": "^1.0.0","gh-pages": "^0.11.0","grunt": "~0.4.5","grunt-contrib-clean": "^1.0.0","grunt-contrib-copy": "^1.0.0","grunt-contrib-cssmin": "^1.0.0","grunt-contrib-nodeunit": "~0.4.1","grunt-contrib-sass": "~0.9.0","grunt-contrib-uglify": "~0.5.0","grunt-shell": "^1.2.1","lite-server": "^2.0.1","typescript": "^1.7.5" },"scripts": { "publish": "node publish.js","tsc": "tsc","tsc:w": "tsc -w","lite": "lite-server","start": "concurrent \"npm run tsc:w\" \"npm run lite\" " } }
tsd.json
{ "version": "v4","repo": "borisyankov/DefinitelyTyped","ref": "master","path": "typings","bundle": "typings/tsd.d.ts","installed": { "leaflet/leaflet.d.ts": { "commit": "1da639a106527e0c4010b354a1efe52a3059a291" } } }
谁能告诉我我做错了什么?
谢谢!
解决方法
System.config({ map: { leaflet: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js' },packages: {'app': {defaultExtension: 'ts'}} }); System.import('app/main') .then(null,console.error.bind(console));
然后你可以这样在你的模块中导入它:
import {Component,OnInit} from 'angular2/core'; import leaflet from 'leaflet';
看到这个plunkr:http://plnkr.co/edit/aUo2uvlxC5ji32u01jfF?p=preview.
Angular 2打字稿到javascript?
所以目前我正在开始一个新项目并想到为什么不开始使用Angular 2.现在我知道每个人都在使用Typescript而不是javascript.但是,我仍然不确定如何在一个简单的Web托管服务器(PHP,HTML,MysqL,Javascript等)上运行项目.
我知道我可以在我的Linux服务器上运行npm start,但是如何将它放在托管服务器上呢?我不能将Typescript编译为javascript,这样我就可以在浏览器中使用它而无需运行npm吗?我读了一些关于JSPM和其他几个的东西,但我不确定这是否是我需要的,也不知道如何使用JSPM或类似的东西(例如使用JSBPM的“5分钟以下快速启动”).
我知道Angular 2有一个javascript部分,这对我有用.但是没有编码示例,您在互联网上找到的所有内容都是Typescript.因此我无法继续在javascript中运行Angular 2,因为缺少教程.
简而言之,我不介意使用Typescript,但我只想要一个纯粹的javascript作为结果,我可以导入HTML并从那里开始.
另外在旁注问题上,运行生产时是否需要存在所有node_modules?
教程的奖励积分可以解释这一点!
谢谢!
解决方法
> https://angular.io/docs/ts/latest/cookbook/ts-to-js.html
它显示了将TypeScript代码转换为ES5代码的方法,它似乎正是您正在寻找的东西.
这是一个示例:
> TypeScript
import { Component } from '@angular/core'; @Component({ selector: 'hero-view',template: '<h1>Hero: {{getName()}}</h1>' }) export class HeroComponent { title = 'Hero Detail'; getName() {return 'Windstorm';} }
> ES5
function HeroComponent() { this.title = "Hero Detail"; } HeroComponent.annotations = [ new ng.core.Component({ selector: 'hero-view',template: '<h1>Hero: {{getName()}}</h1>' }) ]; HeroComponent.prototype.getName = function() {return 'Windstorm';};
在哪里可以这样做;-)
function HeroComponent() { this.title = "Hero Detail"; } var HeroComponent = new ng.core.Component({ selector: 'hero-view',template: '<h1>Hero: {{getName()}}</h1>' }).Class({ constructor: function() { },getName: function() { return 'Windstorm'; } });
关于Angular2应用程序的打包,这个问题也会让您感兴趣:
> How do I actually deploy an Angular 2 + Typescript + systemjs app?
关于angular – 禁用表单打字稿中的所有控件和angular按钮禁用的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Android 动态清空LinearLayout中的所有控件、Angular 12.1 使用打字稿添加 html 元素、Angular 2 – 导入外部传单打字稿库、Angular 2打字稿到javascript?等相关内容,可以在本站寻找。
本文标签: