小编Fra*_*sco的帖子

Angular 4 同一组件之间的动画

我对具有相同组件路径的动画有疑问。例如。我有这条路线:

{路径:'产品/类别/:类别',组件:CategoryComponent},

首先,我解决了路由参数的问题,因为当我在同一组件之间导航时,它们不会刷新 ngOnit() 函数。但现在我已经向我的应用程序添加了动画,并且如果我从 HomeComponent 转到 CategoryComponent,效果会很完美。但是,如果我使用不同的参数从 CategoryComponent 转到 CategoryComponent ,则动画将不起作用。

这是我的动画文件:

import { animate, AnimationEntryMetadata, state, style, transition, trigger } from '@angular/core';

// Component transition animations
export const slideInDownAnimation: AnimationEntryMetadata =
  trigger('routeAnimation', [
    state('*',
      style({
        opacity: 1,
        transform: 'translateX(0)'
      })
    ),
    transition(':enter', [
      style({
        opacity: 0,
        transform: 'translateX(-100%)'
      }),
      animate('0.5s ease-in')
    ]),
    transition(':leave', [
      animate('0.5s ease-out', style({
        opacity: 0,
        transform: 'translateY(100%)'
      }))
    ])
  ]);
Run Code Online (Sandbox Code Playgroud)

这是我的 CategoryComponent.ts

import { Component, OnInit, EventEmitter,Input, Output,HostBinding} from '@angular/core';
import { Pipe, PipeTransform …
Run Code Online (Sandbox Code Playgroud)

angular

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

Angular 2 - 带有promise的Http返回Undefined

我是Angular2的新手,我试图从json文件中获取数据.要做到这一点,我使用Http with Promise,但是当我从我的promise变量中执行console.log时,它们返回Undefined.

post.services.ts

import {Injectable} from '@angular/core';
import { Headers, Http, Response} from '@angular/http'; 
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/toPromise';
import {Post} from '../interfaces/post.interface';
@Injectable()
export class PostService{
    private url = 'myjson.json';
    constructor(private http: Http){ }
    private extractData(res: Response) {
      let body = res.json();
      console.log(body.data);
      return body.data || null;
    }
    getPosts(): Promise<Post[]>{
        return this.http.get(this.url)
            .toPromise()
            .then(this.extractData)
            .catch(this.handleError);
    }   
    private handleError(error: any) {
      console.error('An error occurred', error);
      return Promise.reject(error.message || error);
    }
}
Run Code Online (Sandbox Code Playgroud)

posts.component.js

import { Component, OnInit } from …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-promise angular

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

在Vue.js中实现

我是Vue.js的新手,我想用Materialize制作我的项目.我尝试了很多插件,如:vue-materialize(https://github.com/paulpflug/vue-materialize),vue-material-components(https://www.npmjs.com/package/vue-material-components)并没有奏效.我也尝试将jQuery插件添加到webpack,我没有任何解决方案:

new webpack.ProvidePlugin({
    $: 'jquery',
    jquery: 'jquery',
    'window.jQuery': 'jquery',
    jQuery: 'jquery'
}),
Run Code Online (Sandbox Code Playgroud)

现在我正在努力使工作成为输入选择字段.我怎样才能做到这一点?

javascript jquery materialize vue.js

0
推荐指数
2
解决办法
9233
查看次数