小编Jud*_*ell的帖子

通过Id从数组角度获取对象

我有一个数组:

this.questions = [
      {id: 1, question: "Do you feel a connection to a higher source and have a sense of comfort knowing that you are part of something greater than yourself?", category: "Spiritual", subs: []},
      {id: 2, question: "Do you feel you are free of unhealthy behavior that impacts your overall well-being?", category: "Habits", subs: []},
      {id: 3, question: "Do you feel you have healthy and fulfilling relationships?", category: "Relationships", subs: []},
      {id: 4, question: "Do you feel you …
Run Code Online (Sandbox Code Playgroud)

arrays json angularjs typescript angular

32
推荐指数
3
解决办法
7万
查看次数

Angular 2 AuthGuard服务具有重定向功能?

我有一个我正在构建的应用程序,它在仪表板路由上实现了CanActivate.它在页面重新加载时工作正常,我检查用户服务中的标志以查看用户是否登录.默认情况下,此标志为false,将用户踢出登录.另外在页面重新加载时我试图在localStorage中使用令牌获取使用数据,如果获取成功,我希望它们能够留在仪表板上.问题是我看到了登录的一瞥并且不得不手动将它们重定向到仪表板.有没有办法解决这个问题,直到它检查API之后authGuard没有做任何事情?代码在这里:https://github.com/judsonmusic/tfl

仪表板:

import{ Component , ViewChild} from '@angular/core';
import {LoginComponent} from "../login.component";
import {UserService} from "../user.service";
import {SimpleChartComponent} from "../charts/simpleChart.component";
import {AppleChartComponent} from "../charts/appleChart.component";
import {BarChartComponent} from "../charts/barChart.component";
import {DonutChartComponent} from "../charts/donutChart.component";
import {AlertComponent} from 'ng2-bootstrap/ng2-bootstrap';
import {ModalDemoComponent} from "../modals/modalDemoComponent";
import {NgInitHelperComponent} from "../helpers/nginit.helper.component";
import {ModalDirective} from "ng2-bootstrap/ng2-bootstrap";
import {MODAL_DIRECTIVES, BS_VIEW_PROVIDERS} from 'ng2-bootstrap/ng2-bootstrap';


@Component({
  selector: 'dashboard',
  templateUrl: '/app/components/dashboard/dashboard.component.html',
  providers: [UserService, BS_VIEW_PROVIDERS],
  directives: [SimpleChartComponent, AppleChartComponent, BarChartComponent, DonutChartComponent, AlertComponent, ModalDemoComponent, NgInitHelperComponent, ModalDirective]
})
export class DashboardComponent  {

  public areas:any; …
Run Code Online (Sandbox Code Playgroud)

javascript angular

29
推荐指数
3
解决办法
4万
查看次数

Ionic 2添加自定义构建脚本

我通过CLI使用Ionic 2.在这个版本中,他们使用NPM SCRIPTS而不是gulp.

   "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
 },
Run Code Online (Sandbox Code Playgroud)

我已阅读有关向配置添加自定义脚本但尚不清楚如何执行此操作.这是我目前的配置......

"config": {
    "ionic_bundler": "webpack",
    "ionic_source_map": "source-map",
    "ionic_source_map_type": "eval"
  },
Run Code Online (Sandbox Code Playgroud)

我需要创建一个名为"replace"的自定义脚本它将使用NPM替换.我怎么能添加这个,这样当我运行离子服务或构建时它会运行?

这是我想要运行的gulp代码.

var gulp = require('gulp');
var replace = require('gulp-string-replace');
var p = require('./package.json');
var version = p.version;
gulp.task('serve:after', ['version']);

console.log('Task init!!!');
gulp.task('version', function() {
  gulp.src(["./www/index.html"])
  .pipe(replace(/VERSION/g, p.version))
    .pipe(gulp.dest('./www/'));
});
Run Code Online (Sandbox Code Playgroud)

npm ionic-framework ionic2

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

在Angular 2服务中绑定到数据对象的正确方法?

我正在建立一个角度2应用程序.自发布以来,文档发生了很大的变化,引起了混乱.我能做的最好的事情就是解释我想要做的事情(在Angular 1中这很容易)并希望有人可以帮助我.

我已经使用JWT创建了一个登录服务.登录成功后,我返回一个用户对象.

我有一个loginComponent(将数据绑定到模板)和loginService(处理https调用)

我有一个维护用户对象的userService.

我有一个userComponent,用于呈现用户数据.

问题是,一旦用户登录,我不清楚让userService在名为"user"的对象中检索新数据的最佳方法,然后userComponent更新模板上的用户对象.只需将观察者放在userService.user对象上,就可以轻松实现角度1.

我尝试输入和输出无效,eventEmitters,Observables和getter and setters.getter和setter工作,但强迫我将所有内容存储在"val()"中

有人可以告诉我实现这个目标的最佳方法吗?

  1. 用户组件使用user.firstName,user.lastName等呈现模板.
  2. 最初用户如果是空对象
  3. 登录服务需要设置UserService.user
  4. userComponent需要检测更改并更新DOM.

提前致谢!

javascript angularjs angular

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

使用parallels和Mac上的Visual Studio 2013进行checkin时,TFS访问被拒绝错误

我正在使用TFS在Mac上运行Visual Studio.与此相似,我的项目实际上是指向mac文档文件夹.我能够打开和编辑项目没有问题,并将它们推送到服务器.

最近我启用了TFS源代码控制.每当我尝试进行初始推送或签入时,我都会在所有单个文件上出现"访问路径被拒绝"错误.

我真的不想将我的文件放在虚拟机上,所以有人可以告诉我如何修复权限以允许TFS访问这些文件并进行检入吗?

这是签入时输出窗口的示例...

V:\ MeYearly\packages\Newtonsoft.Json.5.0.6\lib\portable-net45 + wp80 + win8\Newtonsoft.Json.xml:拒绝访问路径.V:\ MeYearly\packages\Newtonsoft.Json.5.0.6\Newtonsoft.Json.5.0.6.nupkg:拒绝访问路径.V:\ MeYearly\packages\Owin.1.0\lib \net40\Owin.dll:拒绝访问路径.V:\ MeYearly\packages\Owin.1.0\Owin.1.0.nupkg:拒绝访问路径.V:\ MeYearly\packages\repositories.config:拒绝访问路径.V:\ MeYearly\packages\Respond.1.2.0\content\Scripts\respond.js:拒绝访问路径.V:\ MeYearly\packages\Respond.1.2.0\content\Scripts\respond.min.js:拒绝访问路径.V:\ MeYearly\packages\Respond.1.2.0\Respond.1.2.0.nupkg:拒绝访问路径.V:\ MeYearly\packages\System.Linq.Dynamic.1.0.0\lib \net40\System.Linq.Dynamic.dll:拒绝访问路径.五:\ MeYearly\packages\System.Linq.Dynamic.1.0.0\System.Linq.Dynamic.1.0.0.nupkg:拒绝访问路径.V:\ MeYearly\packages\Twitter.Bootstrap.3.0.1.1\readme.txt:拒绝访问路径.V:\ MeYearly\packages\Twitter.Bootstrap.3.0.1.1\Twitter.Bootstrap.3.0.1.1.nupkg:拒绝访问路径.V:\ MeYearly\packages\WebGrease.1.5.2\lib\WebGrease.dll:拒绝访问路径.

macos tfs parallels visual-studio visual-studio-2013

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

Angular 2 router.navigate在嵌套的js函数中不起作用

鉴于app模块:

import { NgModule }       from '@angular/core';
import { BrowserModule }  from '@angular/platform-browser';
import { FormsModule }    from '@angular/forms';
import { RouterModule }   from '@angular/router';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

import { AppComponent }        from './app.component';
import {DashboardComponent} from "./components/dashboard/dashboard.component";
import {LogoutComponent} from "./components/logout/logout.component";
import {LoginComponent} from "./components/login/login.component";
import {HttpModule} from "@angular/http";
import {PrescribeComponent} from "./components/prescribe/prescribe.component";
//import { HeroService }         from './hero.service';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    NgbModule.forRoot(),
    RouterModule.forRoot([
      {
        path: 'dashboard',
        component: DashboardComponent
      },
      {
        path: 'logout',
        component: LogoutComponent …
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

离子深层链接打破了刷新

我在Ionic 3中使用Ionic Deeplinker作为Web(浏览器)应用程序

当通过URL传递params时,一切都很好:

HTTP://本地主机:8100 /#/赎回/ 593f2ac1e839b689d883448d

悬停,当我刷新我的应用程序时,我得到:

Uncaught (in promise): invalid link: redeem/593f2ac1e839b689d883448d
Run Code Online (Sandbox Code Playgroud)

我正在使用IonicPage装饰器,如下所示:

@IonicPage({
  name: 'redeem',
  segment: 'redeem/:id',
  defaultHistory: ['reward-goals']
})
Run Code Online (Sandbox Code Playgroud)

为什么当我刷新页面时,我得到了这个错误?

请注意:它没有添加到路线的param工作正常:

HTTP://本地主机:8100 /#/赎回

因此,路由参数的某些内容会导致问题.

更新: 部署我的应用程序时,一切正常,但我仍然在控制台中看到错误. 在此输入图像描述

ionic-framework ionic2 ionic3

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

将数据从 mat 对话框传递回组件

因此,此弹出窗口打开,我可以在 textArea 中写入任何数据,但不幸的是,单击“提交”按钮弹出窗口未关闭,我没有在 ts 文件中获取值。如果我在弹出框之外单击,我会在 TS 中得到未定义的值。

我需要解决这个问题。1. 为什么TextArea数据没有转入TS文件?2. 在文本区域和单击按钮中写入任何数据后,弹出窗口必须关闭,以防止用户单击屏幕的其他部分。

我的 ts 代码是:

if(cnfrm){
let dialogRef = this.dialog.open(this.callAPIDialog)
  dialogRef.afterClosed().subscribe(result => {
  console.log(`Dialog result: ${result}`); // which will be value
})
}
Run Code Online (Sandbox Code Playgroud)

我的html代码是:

 <ng-template #callAPIDialog> 
    <textarea #name matInput placeholder="Leave a comment" formControlName="description" required></textarea> 
    <button type="button" (click)="dialogRef.close(name.value)">Submit</button> 
  </ng-template>
Run Code Online (Sandbox Code Playgroud)

modal-dialog angular

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