相关疑难解决方法(0)

在TypeScript中获取和设置

我正在尝试为属性创建get和set方法:

private _name: string;

Name() {
    get:
    {
        return this._name;
    }
    set:
    {
        this._name = ???;
    }
}
Run Code Online (Sandbox Code Playgroud)

设置值的关键字是什么?

typescript

568
推荐指数
7
解决办法
49万
查看次数

Angular 2.x在body标签上绑定类

由于Angular 2.x是在体内引导的,我如何添加[class.fixed]="isFixed"body标签(在my-app之外)?

<html>
<head>
</head>
<body [class.fixed]="isFixed">
  <my-app>Loading...</my-app>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的app组件看起来像

import {Component} from 'angular2/core';
import {CORE_DIRECTIVES} from 'angular2/common';
import {RouteConfig, ROUTER_DIRECTIVES, Router, Location} from 'angular2/router';
import {About} from './components/about/about';
import {Test} from './components/test/test';

@Component({
    selector: 'my-app',
    providers: [],
    templateUrl: '/views/my-app.html',
    directives: [ROUTER_DIRECTIVES, CORE_DIRECTIVES],
    pipes: []
})

@RouteConfig([
    {path: '/about', name: 'About', component: About, useAsDefault: true},
    {path: '/test', name: 'Test', component: Test}
])

export class MyApp {
    router: Router;
    location: Location;

    constructor(router: Router, location: Location) {
        this.router = …
Run Code Online (Sandbox Code Playgroud)

javascript angular

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

标签 统计

angular ×1

javascript ×1

typescript ×1