我在尝试使用Angular *ngFor和*ngIf同一个元素时遇到了问题.
当尝试遍历集合中的集合时*ngFor,集合被视为null并因此在尝试访问模板中的属性时失败.
@Component({
selector: 'shell',
template: `
<h3>Shell</h3><button (click)="toggle()">Toggle!</button>
<div *ngIf="show" *ngFor="let thing of stuff">
{{log(thing)}}
<span>{{thing.name}}</span>
</div>
`
})
export class ShellComponent implements OnInit {
public stuff:any[] = [];
public show:boolean = false;
constructor() {}
ngOnInit() {
this.stuff = [
{ name: 'abc', id: 1 },
{ name: 'huo', id: 2 },
{ name: 'bar', id: 3 },
{ name: 'foo', id: 4 },
{ name: 'thing', id: 5 },
{ …Run Code Online (Sandbox Code Playgroud) 我想知道如何创建一个响应方块的布局.每个正方形都有垂直和水平对齐的内容.具体示例如下所示......

任何人都可以告诉我如何在我的故事板中隐藏导航栏.我在下面的代码在模拟器中运行时运行正常,但它仍然出现在我的故事板中,这实在令我烦恼,因为它正在弄乱我的图像放置.有人可以帮忙吗?
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
Run Code Online (Sandbox Code Playgroud) 我现在已经花了好几个小时试图弄清楚如何正确地将URLSearchParams依赖注入到组件中.
在我的boot.ts确保包括HTTP_PROVIDERS- 我老实说甚至不确定它是必需的URLSearchParams.
我还确保我在我的页面中包含http包脚本.
boot.ts
bootstrap(AppComponent, [
HTTP_PROVIDERS,
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy}),
PanelsService,
FiltersService
])
Run Code Online (Sandbox Code Playgroud)
这是FiltersService我试图注射的地方URLSearchParams.
filter.service.ts
import {Component, Injectable} from 'angular2/core';
import {URLSearchParams} from 'angular2/http';
@Injectable()
export class FiltersService {
constructor(private _searchParams:URLSearchParams) { }
setFilter(name, value) {
this._searchParams.set(name, value);
}
getFilter(name) {
this._searchParams.get(name);
}
}
Run Code Online (Sandbox Code Playgroud)
URLSearchParams在构造函数中注入会导致错误:
我读过这篇文章,实际上已经几次,无法弄清楚我哪里出错了.
对于它的价值,我在尝试注射时会遇到同样的问题RouteParams.我显然缺少一些基本的东西.
编辑:为了更清楚,这是我的StoriesComponent样子:
import {Component, OnInit} from 'angular2/core';
import {PanelsService} from '../panels/panels.service';
import …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的模型中指定查询
$this->db
->select('*')
->from('library')
->where('library.rating >=', $form['slider'])
->where('library.votes >=', '1000')
->where('library.language !=', 'German')
->where('library.available_until >=', date("Y-m-d H:i:s"))
->or_where('library.available_until =', "00-00-00 00:00:00")
->where('library.release_year >=', $year_start)
->where('library.release_year <=', $year_end)
->join('rating_repo', 'library.id = rating_repo.id')
Run Code Online (Sandbox Code Playgroud)
所以,我遇到的麻烦就是我的or_where.我希望or仅限于该available_until领域.然而,目前,我得到的结果是德语不是我想要的.如何将我的or_where过滤器限制在该available_until字段中?
我试图将Http服务注入我的服务器时遇到此错误PanelsService.
import {Component} from 'angular2/core';
import {Http} from 'angular2/http';
export class PanelsService {
constructor(public http:Http) { }
getPanelFilters() {
var url = '../../data/panelFilters/' + 13677 + '.json'
return this.http.get(url)
}
}
Run Code Online (Sandbox Code Playgroud)
我正试图PanelsService从我的访问SidebarComponent:
import {PanelsService} from '../panels/panels.service';
@Component({
....
providers: [PanelsService]
})
export class SidebarComponent implements OnInit {
constructor(public panelsService:PanelsService) { }
ngOnInit() {
console.log('I am the sidebar component');
}
}
Run Code Online (Sandbox Code Playgroud)
应该指出的是,我tsconfig.json的行也有:
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Run Code Online (Sandbox Code Playgroud)
我试过使用这里@Injectable演示但是当我装饰我的类时,我在控制台中出现错误:@Injectable() …
我一直在寻找解决这个问题的时间,但找不到适合我的方法.当我点击我网站上的"注销"时,用户信息仍然可见,并且仍然显示注销按钮.这是代码:
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxx',
'secret' => 'xxxx',
));
// Get User ID
$user = $facebook->getUser();
var_dump($user);
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($_GET['logout'] == "yes") {
setcookie('fbs_'.$facebook->getAppId(), '', time()-100, '/', 'http://gno.....ment/index.php');
session_destroy();
header("Location: ".$_SERVER['PHP_SELF']."");
}
if …Run Code Online (Sandbox Code Playgroud) 我在播放本地.wav文件时遇到了一些麻烦.我AVPlayerStatus是打印0,我假设它意味着它还没准备好玩.我似乎无法弄清楚但是说过,这是我第一次尝试使用AVPlayer做任何事情,所以它可能很简单.我很感激任何帮助.这是代码:
我应该补充说我的声音没有播放!
-(void) playWordSound:(UILabel *)label
{
NSString *path;
switch (label.tag)
{
case 1:
path = [[NSBundle mainBundle] pathForResource:@"humpty" ofType:@"wav"];
break;
case 2:
path = [[NSBundle mainBundle] pathForResource:@"dumpty" ofType:@"wav"];
break;
case 3:
path = [[NSBundle mainBundle] pathForResource:@"saty" ofType:@"wav"];
break;
case 4:
path = [[NSBundle mainBundle] pathForResource:@"on 2" ofType:@"wav"];
break;
case 5:
path = [[NSBundle mainBundle] pathForResource:@"a 3" ofType:@"wav"];
break;
case 6:
path = [[NSBundle mainBundle] pathForResource:@"wall" ofType:@"wav"];
break;
}
NSURL *url = [NSURL fileURLWithPath:path];
AVQueuePlayer *player;
static …Run Code Online (Sandbox Code Playgroud) 我有许多动画在加载我的根视图控制器时自动启动.这些动画包括在内viewDidLoad.当我导航到我的下一个视图控制器并返回到根视图控制器时,所有动画都已停止.当我按下"主页"按钮然后返回到视图时,会出现相同的行为.
我敢肯定我在这里遗漏了一些非常基本的东西但是会感激任何帮助.谢谢.
编辑1:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self beeBobbing];
//animate the butterfly oscillating
[self butterflyOscillate];
}
-(void) beeBobbing
{
[UIView animateWithDuration:1.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction ) animations:^{
CGPoint bottomPoint = CGPointMake(215.0, 380.0);
imgBee.center = bottomPoint;
} completion:^(BOOL finished) {
}];
}
Run Code Online (Sandbox Code Playgroud)
编辑2:在视图之间切换时,这种类型的动画似乎重新启动:
-(void) animateClouds
{
[UIView animateWithDuration:30.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter; …Run Code Online (Sandbox Code Playgroud) 为了提供一些上下文,我有一个<video>标记,该标记具有src指向我的 node.js 服务器上的方法的属性。该方法mp4从另一台服务器获取文件,或者更确切地说是文件的一部分mp4,具体取决于Range浏览器指定的HTTP 标头,例如 - Range:bytes=0-。
预期行为(Chrome 行为)
为了防止我的 node.js 服务器从第三方服务器下载整个文件,我实现了大约 5MB 的最大缓冲区,以便一次下载。因此,如果用户发送请求以获取带有标题的视频
GET /play-test/videoId HTTP/1.1
Host: 127.0.0.1:8000
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Accept: */*
Referer: http://127.0.0.1:8000/movie/99861
Accept-Language: en-US,en;q=0.8,es;q=0.6
Range: bytes=0-
Run Code Online (Sandbox Code Playgroud)
..然后我的服务器将响应
HTTP/1.1 206 Partial Content
X-Powered-By: Express
Content-Range: bytes 0-5000000/415473786
Connection: keep-alive
Accept-Ranges: bytes
Content-Length: 5000001
Content-Type: video/mp4
Date: …Run Code Online (Sandbox Code Playgroud) angular ×3
ios ×3
iphone ×3
objective-c ×2
php ×2
activerecord ×1
animation ×1
aspect-ratio ×1
audio ×1
avplayer ×1
codeigniter ×1
css ×1
facebook ×1
firefox ×1
grid-layout ×1
html ×1
html5-video ×1
http ×1
http-range ×1
ipad ×1
javascript ×1
mysql ×1
ngfor ×1
node.js ×1
oauth ×1