小编Kri*_*ore的帖子

Bootstrap在Angular 6应用程序中不起作用

我想在Angular 6应用程序中使用Bootstrap,这是我到目前为止所做的,但似乎没有任何工作:

1)使用npm安装bootstrap,jquery和popper.js.2)在Angular.json文件中输入以下内容

"styles": [
    "src/styles.scss",
    "node_modules/bootstrap/scss/bootstrap.scss"
],
"scripts": [
    "node_modules/jquery/dist/jquery.slim.min.js",
    "node_modules/popper.js/dist/umd/popper.min.js",
    "node_modules/bootstrap/dist/js/bootstrap.min.js"
    ...
]
Run Code Online (Sandbox Code Playgroud)

我错过了什么.这似乎没有成功.

jquery twitter-bootstrap bootstrap-4 angular angular6

3
推荐指数
2
解决办法
2289
查看次数

在角度/打字稿中将类创建为 Iterable

我已经在 angular 中创建了一个类,现在当我通过商店订阅获取一个对象时,虽然它返回一个对象数组,但我不能在返回的对象上使用 forEach 循环。

是的,我使用了Object.keys(user).forEach(){..}它正在工作,但我想通过使类 Iterable 来做同样的事情。如何做到这一点。

示例代码:-

class user {
    ...
}
ngOnInit(){
    storeSubsc = this.store.select('users').subscribe(user => {
        this.user = user;
    });
}

login(){
    Object.keys(this.user).forEach()... --> working fine
    I want it like
    this.user.forEach() {... }
}
Run Code Online (Sandbox Code Playgroud)

提前致谢...

iterable typescript angular

3
推荐指数
1
解决办法
2161
查看次数

ngModel 在表单标签中不起作用

[(ngModel)] 不能在表单标签内工作

当我使用 Multi Select Outside Form 标签时,可以正常选择 All 和 Deselect All 功能

但是我当我把它放在表格里面时它工作选择所有值

<form [formGroup]="roleForm">

    <mat-form-field class="example-full-width">
        <mat-select placeholder="Select Role Type" formControlName="roleType" (selectionChange)="roleTypeSelect($event.value)">
            <mat-option *ngFor="let role of roleTypeList" [value]="role.roleTypeId">
                {{role.roleTypeName}}
            </mat-option>
        </mat-select>
    </mat-form-field> <!-- Multi Select Mat Start -->
    <mat-form-field class="example-full-width">

        <mat-select placeholder="Select Privileges" class="filter-select" [formControl]="selectedItems" [compareWith]="equals" multiple
         #privilegeSelect="ngModel">
            <mat-option disabled="disabled" class="filter-option">
                <button mat-raised-button class="mat-primary fill text-sm" (click)="selectAll(privilegeSelect, dropdownList)">
                    Select All
                </button>
                <button mat-raised-button class="mat-primary fill text-sm eta-margin-all" (click)="deselectAll(privilegeSelect)">
                    Deselect All
                </button>
            </mat-option>
            <mat-option *ngFor="let privilege of dropdownList" [value]="privilege">{{privilege.itemName}}</mat-option> …
Run Code Online (Sandbox Code Playgroud)

multi-select angularjs-directive angular-material angular

2
推荐指数
1
解决办法
1985
查看次数

Angular 如何设置 routerLink 的样式

我的应用程序中有很多表格行。有些是链接,有些不是。这是一个例子:

<tr [routerLink]="['/invoices', invoice?.invoice.id || 0, 'sms']">
Run Code Online (Sandbox Code Playgroud)

我想用这样的 routerLink 设置所有 tr 的样式:

tr[routerLink] {
   cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用。这里正确的 CSS 是什么?谢谢

html angular

2
推荐指数
1
解决办法
3691
查看次数

如何将我的Json数组转换为angular 5中的对象

我有一个像这样的Json数组:

[{"name":"ip","children":{"label":"ip","value":"","type":"text","validation":"{ required: true}"}}
,{"name":"test","children":{"label":"test","value":"","type":"text","validation":"{ required: true}"}}
,{"name":"join","children":{"label":"join","value":"","type":"text","validation":"{ required: true}"}}
,{"name":"myform","children":{"label":"myform","value":"","type":"text","validation":"{ required: true}"}}]
Run Code Online (Sandbox Code Playgroud)

我应该将一个对象传递给这样的组件

export const person = { 
    ip: {
        label: 'ip',
        value: '',
        type: 'text',
        validation: { required: true }
    },
     test: {
        label: 'test',
        value: '',
        type: 'text',
        validation: { required: true }
    },
    join: {
        label: 'join',
        value: '',
        type: 'text',
        validation: { required: true }
    },
    myform: {
        label: 'myform',
        value: '',
        type: 'text',
        validation: { required: true }
    }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

typescript angular

1
推荐指数
1
解决办法
80
查看次数

如何从jQuery调用Angular方法

这个问题类似于使用Jquery调用Angular函数

但我认为我的例子有很小的不同.

Angular项目上我有一个按钮:

<button id="button1" #tbName title="tbName" class="btn btn-lg btn-outline-primary" (click)="open(content,tbName.title)">Launch demo modal</button>
Run Code Online (Sandbox Code Playgroud)

在TS文件上有一个方法:

open(content, title) {
    console.log(document.getElementById('button1').getAttribute('title'));
    this.id_desk = document.getElementById('button1').getAttribute('title');
    this.modalService.open(content, { centered: true, container: '#test', ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {

        this.closeResult = `Closed with: ${result}`;
    }, (reason) => {

        this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
    });
}
Run Code Online (Sandbox Code Playgroud)

怎么看起来像jQuery函数会直接调用open(content,title)angular方法?

jquery angular

1
推荐指数
1
解决办法
64
查看次数