题:
如何$mdToast在不触发错误的情况下在拦截器内部使用?
建立:
拦截器定义:
(function () {
'use strict';
angular
.module('app.components.http-errors-interceptors')
.factory('HttpError500Interceptor', HttpError500Interceptor);
/* @ngInject */
function HttpError500Interceptor($q,
$mdToast,
$filter) {
var interceptor = {};
interceptor.responseError = responseError;
function responseError(responseError) {
if (responseError.status === 500) {
$mdToast.show($mdToast.simple()
.content($filter('translate')('APP.COMPONENTS.HTTP_ERRORS_INTERCEPTORS.500'))
.position('bottom right')
.hideDelay(5000));
}
return $q.reject(responseError);
}
return interceptor;
}
})();
Run Code Online (Sandbox Code Playgroud)
拦截器配置:
(function () {
'use strict';
angular
.module('app.components.http-errors-interceptors')
.config(moduleConfig);
/* @ngInject */
function moduleConfig($httpProvider) {
$httpProvider.interceptors.push('HttpError500Interceptor');
}
})();
Run Code Online (Sandbox Code Playgroud)
问题:
当我加载应用程序时,它会触发以下错误:
未捕获错误:[$ injector:cdep]找到循环依赖项:$ http < - $ templateRequest < - …
javascript circular-dependency angularjs angular-http-interceptors angularjs-material
因此,我今天\xe2\x80\x99m 测试了 CLI,并firebase init选择了 db/hosting,并选择创建一个新项目,总是显示Error: Permission denied..
sudo firebase init\xe2\x80\x99 没有帮助。
firebase-tools3.0.3OS X 10.11.5 上的版本。
firebase init\n\nYou\'re about to initialize a Firebase project in this directory:\n\n /Users/splaktar/Git/tmp\n\nBefore we get started, keep in mind:\n\n * You are initializing in an existing Firebase project directory\n\n? What Firebase CLI features do you want to setup for this folder? Database: Deploy Firebase Realtime Database Rules\n\n=== Project Setup\n\nFirst, let\'s associate this project directory with a …Run Code Online (Sandbox Code Playgroud) 目标:使用组件而不是使用$ scope来设置数据.没有要共享的错误,问题是对话框加载组件时未设置数据元素.屏幕截图显示了对话框的当前状态,应该在选项卡#2(信息)中绑定一个对象.在使用onComplete事件加载对话框后,我可以验证对象(文档)是否可用.我试图通过以下方式将对话框调用可用的数据绑定到组件:
locals: {
document: document
},
bindToController: true,
onComplete: function(){
console.log('document: %O', document);
}
Run Code Online (Sandbox Code Playgroud)
bindings: {
document: '='
}
Run Code Online (Sandbox Code Playgroud)
resolve: {
document: function() {
return document;
}
}
Run Code Online (Sandbox Code Playgroud)
我相信错误在这里,绑定,"旧方式"使用$ scope vars所以绑定毫不费力地连接.
(function(){
'use strict';
angular.module('adminClientApp')
.component('documentEdit', {
templateUrl: 'js/app/components/document/documentEdit/document-edit.html',
controller: function DocumentEditController($mdToast, $mdMedia) {
var var documentEdit = this;
documentEdit.document;
},
bindings: {
document: '<'
}
});
})();
Run Code Online (Sandbox Code Playgroud)
DialogController中只有$ mdDialog事件.我意识到locals和bindToController都是针对对话框中指定的控制器(DialogController).我在这里难过 - 如何设置/传递/连接文件到组件控制器?
this.showEdit = function ($event, document) {
var parentEl = angular.element(document.body);
$mdDialog.show({
parent: …Run Code Online (Sandbox Code Playgroud) 我正在使用带有Typescript的Angular 2构建应用程序。我的setter和getter应该具有哪种返回类型?
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Events, SqlStorage, Storage } from 'ionic-angular';
import { Subject } from 'rxjs/Subject';
export interface User {
name?: string,
email?: string,
gender?: string,
picture?: Object
}
export interface DataStore {
user: User
}
@Injectable()
export class UserService {
private storage: Storage;
private _user$: Subject<User>;
private dataStore: DataStore;
constructor(
private http: Http
) {
this.storage = new Storage(SqlStorage);
this._user$ = new Subject();
this.dataStore = { …Run Code Online (Sandbox Code Playgroud) 我有一个需要身份验证的下游 Sinopia 存储库,我想在 Artifactory 中将其设置为远程 npm 存储库。我如何向 Artifactory 提供遥控器的凭据?
我使用原始angular2材质框架中的md-fab-button.我想设置md-fab-button(用于添加新实体),position: fixed但我想将按钮放在内部组件中md-sidenav-layout但如果我这样做则position: fixed不起作用.
上面的代码:
<div class="{{themeService.ActualTheme}}">
<md-sidenav-layout class="full-height" fullscreen>
Run Code Online (Sandbox Code Playgroud)
这个类属性仅用于主题应用程序我也尝试过它没有全屏,并设置类"全高" md-sidenav-layout到100%高度和绝对,但它不起作用.
首先尝试(position: fixed不起作用):
<button (click)="onPlusClickAction()" class="add-group-button" color="accent" md-fab>
<md-icon class="md-24 plus-icon">add</md-icon>
</button>
</md-sidenav-layout>
</div>
Run Code Online (Sandbox Code Playgroud)
而不是router-outlet内部组件将被替换(标准angular2路由).
现在我试着把md-fab-button放在这里:
<router-outlet></router-outlet>
</md-sidenav-layout>
<button (click)="onPlusClickAction()" class="add-group-button" color="accent" md-fab>
<md-icon class="md-24 plus-icon">add</md-icon>
</button>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我这样做,那么position: fixed工程,但现在md-fab-button md-sidenav-layout在我之外,并且当我打开我的sidenav时,fab-button放在sidenav上.z-index不起作用,因为fab-button完全消失.
谁有好主意解决这个问题?
先感谢您!
我已经检查了这个问题的github问题,并查看了各种堆栈溢出问题和博客和内容,我找不到解决方案,为什么我在我的角度2应用程序中运行"ng test"时出现此错误.
这是测试的样子:
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { RouterModule } from "@angular/router";
import { Location,LocationStrategy } from "@angular/common";
describe('App: MemberAdmin', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports:[
RouterModule
],
providers:[
Location,
LocationStrategy
]
});
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app works!'`, async(() => {
let fixture = TestBed.createComponent(AppComponent); …Run Code Online (Sandbox Code Playgroud) 我正在学习Angular2 RC5Angular2材料库并让它在AspNetCore 1.0应用程序中运行,VisualStudio 2015.我使用了一个运行良好的Angular2 RC5单页面应用程序,并试图引入延迟加载,其中只有登录页面将首先加载.当我成功登录后,我想加载剩余的页面.
当我在SPA模式下单击登录按钮时,我会成功重定向到预先加载了登录页面的DashboardComponent页面 - 这是在我引入延迟加载之前.按照本教程后,我现在得到这些错误
错误代码段
Run Code Online (Sandbox Code Playgroud)EXCEPTION: Error: Uncaught (in promise): Template parse errors: Can't bind to 'ngIf' since it isn't a known property of 'md-card-title'. 1. If 'md-card-title' is an Angular component and it has 'ngIf' input, then verify that it is part of this module. 2. If 'md-card-title' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. …
我有模态形式,我想在我的模态形式中使用自动重现字段.
要,我使用的是实现这一目标md-autocomplete的angular-material#1.1.0,它提供了这样的功能和易于使用.
问题是当我在这个字段中写一些东西时,整个建议列表出现在我的模态窗口后面,但它应该出现在这个模态窗体的顶部.
你知道如何解决这个问题吗?
我附加了表单源和相关角度控制器的html代码.
movie-resource-dialog-controller.js
(function() {
'use strict';
angular
.module('vodApp')
.controller('MovieResourceDialogController', MovieResourceDialogController);
MovieResourceDialogController.$inject = ['$http', '$timeout', '$scope', '$stateParams', '$uibModalInstance', 'DataUtils', 'entity', 'MovieResource', 'Movie'];
function MovieResourceDialogController ($http, $timeout, $scope, $stateParams, $uibModalInstance, DataUtils, entity, MovieResource, Movie) {
var vm = this;
vm.movieResource = entity;
vm.clear = clear;
vm.byteSize = DataUtils.byteSize;
vm.openFile = DataUtils.openFile;
vm.save = save;
$timeout(function (){
angular.element('.form-group:eq(1)>input').focus();
});
function clear () {
$uibModalInstance.dismiss('cancel');
}
function save () {
vm.isSaving = true;
if (vm.movieResource.id !== …Run Code Online (Sandbox Code Playgroud) 我遇到了Angular2的材质md-select组件的问题,其中FormGroup的值未加载或填充到select中.这是代码......
https://embed.plnkr.co/p7Fm9lC4TxoVaZ8ydYf0/
控件'formal'的值设置为1,但UI显示为没有使用占位符消息填充值.
难道我做错了什么?
我已经调试了这个问题几天,没有任何运气.我必须遗漏一些相当明显的东西.我正在运行与JavaFX 2.2打包工具打包在一起的Swing应用程序,它通过JNI连接到C .dll.
一切都很好,直到我想添加一个函数从C调用回Java.当我这样做时,我开始遇到内存损坏问题.这是错误,然后是我的新JNI代码:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c82c912, pid=7424, tid=4828
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) Client VM (24.0-b56 interpreted mode windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x2c912]
#
# Core dump written.
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
--------------- T H R E …Run Code Online (Sandbox Code Playgroud) 我正在使用Material Design的md-dialog,我遇到了一个小问题,这给我带来了很多麻烦.
我正在使用此对话框作为在db中创建新记录的表单,我需要从外部文件加载其控制器.原因是我在应用程序的许多地方(在许多其他控制器中)使用相同的对话框,我不想复制并粘贴到它们中的每一个.
我试图把它写成一个服务,但问题是,因为我将数据从表单绑定到控制器我使用$ scope,这样我就得到了"$ scope未定义".当我在该服务中添加$ scope作为依赖项时,我会注入错误.你有任何想法如何从外部加载模态控制器,所以它甚至可以使用$ scope吗?
$scope.showNewContactDialog = function($event) {
var parentEl = angular.element(document.body);
$mdDialog.show({
parent: parentEl,
targetEvent: $event,
templateUrl: 'app/Pages/directory/contacts/newContact.dialog.html',
controller: NewCompanyContactDialogCtrl,
clickOutsideToClose: true,
hasBackdrop: true
});
};
// New User dialog controller
function NewCompanyContactDialogCtrl($scope, $mdDialog) {
var self = this;
$scope.modalIcon = "add";
$scope.modalTitle = 'Nová položka';
$scope.modalAdvanced = true;
// Country Selector
apiCalls.getData(countryUrl, function(response){
$scope.countries = response;
})
// Add New Object
$scope.newItem = function() {
var url = baseUrl + 'new/';
var data = …Run Code Online (Sandbox Code Playgroud) angular ×5
angularjs ×4
css ×2
javascript ×2
typescript ×2
angular-cli ×1
artifactory ×1
c ×1
css3 ×1
firebase ×1
html ×1
mddialog ×1
modal-dialog ×1
observable ×1
rxjs ×1
sinopia ×1
unit-testing ×1
verdaccio ×1