小编Ama*_*mar的帖子

Angular 2更改HTML元素的文本

我想更改html元素的文本.

profile.component.html

<div class="col col-sm-12">
  <h2>FirstName LastName</h2>
</div>
Run Code Online (Sandbox Code Playgroud)

profile.component.ts

changeName():void{
        //Code to change the <h2> element
    }
Run Code Online (Sandbox Code Playgroud)

如果你能提供代码示例如何做到这一点,那就太好了!

html typescript angular

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

PrimeNg CSS 不工作

我可以得到<button pButton type="button" class="ui-button-danger"></button>,但它不会风格化。我已在我的index.html 中链接了primeng.min.css。但我假设我的.angular-cli.json文件有错误,因为样式部分是空的。

编辑:控制台错误说:无法加载资源:服务器响应状态为 404(未找到),但<link rel="stylesheet" type="text/css" href="/node_modules/primeng/resources/primeng.min.css" />我已经仔细检查过,它就在那里。

html css primeng angular

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

如何将纳秒转换为秒?

有没有办法将 event.timestamp 转换为常规指标。我当前的输出是 267185117663619(纳秒??)。有没有办法将其转换为毫秒甚至秒?

  timestamp = String.valueOf(event.timestamp);
Run Code Online (Sandbox Code Playgroud)

提前致谢!

java time android timestamp android-studio

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

通过 routerLink 将参数传递给新组件

我想在按下 list-profile html doc 中提供的链接后发送一个变量。当前代码不起作用并且崩溃了。如果需要,我可以提供更多细节。

列表-profile.component.html

<div class="col col-sm-4 col-sm-offset-4">
    <ul  id="list_of_users">
        <li class="list-group-item list-group-item-action" *ngFor="let user of users"><a [routerLink]="['/profile', user.id]"  routerLinkActive="active" (click)="testFunc(user.id)">{{user.name}}</a></li>
    </ul>
</div>
Run Code Online (Sandbox Code Playgroud)

app.module.ts

const appRoutes: Routes = [
{ path: 'addProfile', component: AddProfileComponent },
{ path: 'listProfiles', component: ListProfilesComponent},
{ path: 'profile:id', component: ProfileComponent}
];
Run Code Online (Sandbox Code Playgroud)

html parameters routing components angular

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

$emit 在计算之前执行

我正在尝试发出一个我修改过的道具。我可以直接使用 prop 来做到这一点,它可以工作,但我收到一个 Vue 警告:Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders

因此,我尝试将 prop 放入计算中,但在执行计算之前执行发射。

template:
          <input
                v-on:keyup="validatedate(localDate)"
                v-on:change="emitAnswer(localDate)"
                v-model="localDate">
 ,
 computed: {
    dateLocal: {
        get: function () {
            return this.date
        }
 }
 methods: {
     emitAnswer: function (date) {
        this.$emit('myFunc', date);
    }
 }
Run Code Online (Sandbox Code Playgroud)

javascript data-binding vue.js

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