小编Sna*_*ops的帖子

使用任何动画/过渡时Webkit边界半径和溢出错误

我有收到一个奇怪的错误,当我使用的组合overflow,border-radiustransition.我有一个div里面有一个img.div具有边框半径和溢出设置为隐藏.当我将鼠标悬停在img上时,我发生了一个过渡,使图像变大以创建缩放效果.问题是溢出似乎在图像的左下角和右下角中断.

我为你创造了一个jsfiddle,看看我在说什么.http://jsfiddle.net/dmcgrew/HuMrC/1/

它在Firefox中运行良好,但在Chrome和Safari中中断.

任何人都知道可能导致此问题或如何修复它?

css safari webkit google-chrome overflow

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

Angular2快速入门 - '无法获取'消息

我一直在尝试为Angular2做快速入门指南.我按照快速指南中的说明做了例子.但是,当我运行它时,它显示以下消息'无法获取'.有谁知道为什么会这样?

boot.js文件

// JavaScript source code
(function (app) {
    document.addEventListener('DOMContentLoaded', function () {
        ng.platform.browser.bootstrap(app.AppComponent);
    });
})(window.app || (window.app = {}));
Run Code Online (Sandbox Code Playgroud)

app.component.js文件

(function (app) {
    app.AppComponent = ng.core.Component({
        Selector: 'my-app',
        template: '<h1>My First Angular 2 App </h1>'
    })
    .class({
        constructor: function () { }
    });
})(window.app || window.app == {});
Run Code Online (Sandbox Code Playgroud)

索引文件

<html>

<head>
    <title>Angular 2 QuickStart</title>

    <!-- 1. Load libraries -->
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/Rx.umd.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-all.umd.dev.js"></script>

    <!-- 2. Load our 'modules' -->
    <script src='app/app.component.js'></script>
    <script src='app/boot.js'></script>

</head>

<!-- 3. Display …
Run Code Online (Sandbox Code Playgroud)

javascript node.js angular

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

AngularJs 2 - 创建了多个服务实例

我创建了AngularJS 2服务,并在2个不同的组件中使用它:App-Component&Sub-Component.每个输出属性'log'(一个字符串)我的服务.

StateService类:

@Injectable ()
class StateService {

    public log : string;
    static count : number = 0;

    constructor () {
        this.log = '';
        StateService.count++;
        this.writeToLog ('CREATED '+StateService.count+' at ' + new Date().toString());
    }

    public writeToLog (text : string) : void {
        this.log += text + '\n';
    }
}  
Run Code Online (Sandbox Code Playgroud)

零件 :

@Component ({
    selector : 'Sub-Component',
    template : `<hr>
            This is the Sub-Component !
            <BR>
            StateService Log : 
            <pre>{{ _stateService.log }}</pre>
            <button (click)="WriteToLog ()">Write to log</button>
            `,
    providers : [StateService] …
Run Code Online (Sandbox Code Playgroud)

angular2-services angular

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

如何在多个Angular 2项目之间共享Angular 2组件?

理想情况下,我想创建一个独立的Angular 2组件(带有测试),然后在两个或三个不同的Angular 2站点之间重用它.实现这一目标的好方法是什么?还有一个额外的问题 - 是否存在任何第三方Angular 2组件?

javascript web-component angular

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

Angular2观察路线变化

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

export class MyApp {
    router: Router;
    location: Location;
    isCollapsed: boolean = true;

    // ON ROUTE CHANGE {
        this.isCollapsed = true;
    // }

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

我需要在每次路线更改时更改变量值,如何在Angular 2.x中观察此事件?

typescript angular

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

在Angular 2中为模拟数据创建一个Observable

我试图从具有模拟数据的服务返回一个Observable.

我从我的服务中退回来了:

return Observable.of(new Object()).map(MOCKACCOUNT =>JSON.stringify(MOCKACCOUNT));
Run Code Online (Sandbox Code Playgroud)

我收到一个错误

Observable_1.Observable.of不是一个函数.

我错过了一些包括?我正在进口

import {Observable} from "rxjs/Observable";
Run Code Online (Sandbox Code Playgroud)

注意:我之前返回了一个模拟承诺,但根据我的理解,我无法插值.例如{{returnFromServiceStoredInExportedClass.name}}

promise observer-pattern angular

25
推荐指数
2
解决办法
2万
查看次数

如何在Angular 2中使用Less?

我想知道如何为Angular 2项目添加更少的编译.因为每个组件都有自己的.css文件(现在它将是.less文件)我不知道如何将文件编译为css ...

我也搜索了这个问题而没有找到解决问题的办法.

编辑为了使我的问题更清楚:我希望每个组件都有一个.less,就像它在Angular 2中的.css文件一样默认.我只想要每个.less都要预编译,因为Angular包括在Angular处理组件之后,css作为内联脚本,我想我之间需要一些较少的预处理脚本,它是否存在?

对于整个项目,我宁愿没有一个大的.less文件包含手册,这当然是一个可能的解决方案.这个解决方案似乎不符合Angular环境,但......

less angular

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

管道中的Angular 2依赖注入

我如何将像服务这样的依赖项注入angular2管道?

import {Pipe, PipeTransform} from 'angular2/core';
import {MyService} from './service';

//How i am injecting MyService to the pipe?

@Pipe({name: 'exponentialStrength'})
export class ExponentialStrengthPipe implements PipeTransform {
  transform(value:number, args:string[]) : any {
    return Math.pow(value, parseInt(args[0] || '1', 10));
  }
}
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

在Angular 2 ngOnInit中测试承诺

我有一个Angular 2组件我试图进行测试,但是我遇到了麻烦,因为数据是在ngOnInit函数中设置的,所以在单元测试中不能立即使用.

用户view.component.ts:

import {Component, OnInit} from 'angular2/core';
import {RouteParams} from 'angular2/router';

import {User} from './user';
import {UserService} from './user.service';

@Component({
  selector: 'user-view',
  templateUrl: './components/users/view.html'
})
export class UserViewComponent implements OnInit {
  public user: User;

  constructor(
    private _routeParams: RouteParams,
    private _userService: UserService
  ) {}

  ngOnInit() {
    const id: number = parseInt(this._routeParams.get('id'));

    this._userService
      .getUser(id)
      .then(user => {
        console.info(user);
        this.user = user;
      });
  }
}
Run Code Online (Sandbox Code Playgroud)

user.service.ts:

import {Injectable} from 'angular2/core';

// mock-users is a static JS array
import {users} from …
Run Code Online (Sandbox Code Playgroud)

jasmine angular

18
推荐指数
2
解决办法
2万
查看次数

IE 11是否忽略autocomplete ="off"?

我正在研究一个成熟的ASP.NET/C#应用程序(它已经有三年了).出于各种原因,我最近开始使用测试版IE 11.但是,当我第一次在浏览器中启动应用程序时,我注意到它问我是否希望Internet Explorer记住此站点的密码.这不会发生在应用程序支持的任何其他浏览器或其他版本的IE中,因为存在autocomplete ="off",例如

<form id="form1" runat="server" autocomplete="off">
Run Code Online (Sandbox Code Playgroud)

这是在IE 11中被嘲笑(我知道这只是测试版,但我有点担心)?

html forms internet-explorer-11

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