ngb-alert only works with type="success" or without type - ng-bootstrap

I have this following code which works.
<ngb-alert *ngIf="alertError" class="fade animate-show animate-hide" (close)="alertError = false"><strong>{{ message }}</strong></ngb-alert>
<ngb-alert *ngIf="alertSuccess" class="animate-show animate-hide" type="success" (close)="alertSuccess = false"><strong>{{ message }}</strong></ngb-alert>
But if I change to the following it doesn't
<ngb-alert *ngIf="alertError" class="fade animate-show animate-hide" type="danger" (close)="alertError = false"><strong>{{ message }}</strong></ngb-alert>
<ngb-alert *ngIf="alertSuccess" class="animate-show animate-hide" type="primary" (close)="alertSuccess = false"><strong>{{ message }}</strong></ngb-alert>
My package.json is like this.
"dependencies": {
"#angular/animations": "^4.3.4",
"#angular/cdk": "^2.0.0-beta.8",
"#angular/common": "^4.3.4",
"#angular/core": "^4.3.4",
"#angular/forms": "^4.3.4",
"#angular/http": "^4.3.4",
"#angular/material": "^2.0.0-beta.8",
"#angular/platform-browser": "^4.3.4",
"#angular/platform-browser-dynamic": "^4.3.4",
"#angular/router": "^4.3.4",
"#ng-bootstrap/ng-bootstrap": "~1.0.0-alpha.30",
"angular-loader": "^1.6.5",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"primeng": "^4.1.3",
"rxjs": "^5.4.2",
"screenshot-desktop": "^1.1.0",
"underscore": "^1.8.3",
"zone.js": "^0.8.16"
},
"devDependencies": {
"#angular/cli": "^1.2.7",
"#angular/compiler": "^4.3.4",
"#angular/compiler-cli": "^4.3.4",
"#types/jasmine": "^2.5.53",
"#types/node": "^8.0.19",
"codelyzer": "^3.1.2",
"jasmine-core": "^2.7.0",
"jasmine-spec-reporter": "^4.1.1",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.1.2",
"ts-node": "^3.3.0",
"tslint": "^5.5.0",
"typescript": "^2.4.2"
}
So, can some expert please tell me what's wrong here? Why type primary or danger won't work.

I ran across a similar issue. My problem was that Angular thought I was passing it a variable from which to read the type from. Obviously there was no variable titled primary so it failed. changing things to [type]="'primary'" solved the issue altogether.
<ngb-alert *ngIf="alertSuccess" class="animate-show animate-hide" [type]="'primary'" (close)="alertSuccess = false"><strong>{{ message }}</strong></ngb-alert>

I think you're just not allowed to use the fade class here.
class="fade animate-show animate-hide"
If I run your code, it only shows me the success.
But if I remove the fade class, it shows both messages.
EDIT
I compared your list of dependencies to mine.
Have you tried updating your libs?
You can run this from the command line:
npm update -D && npm update -S
Dependencies that you have, that I don't :
"angular-loader": "^1.6.5",
"font-awesome": "^4.7.0",
"primeng": "^4.1.3",
"screenshot-desktop": "^1.1.0",
"underscore": "^1.8.3"
I am especially wondering about that first one angular-loader.
Do you know what it's for ? According to its documentation it's a AngularJS dependency.

Related

ERROR Error: Uncaught (in promise): TypeError: i.BehaviorSubject is not a constructor in Angular 10 SSR

I'm getting this issue after build successfully and run on browser with angular universal
Here is my package json :
{
"name": "ssr",
"version": "1.0.0",
"private": true,
"dependencies": {
"#angular/animations": "10.0.5",
"#angular/cdk": "10.1.0",
"#angular/common": "10.0.5",
"#angular/compiler": "10.0.5",
"#angular/core": "10.0.5",
"#angular/fire": "^6.0.2",
"#angular/forms": "10.0.5",
"#angular/http": "^7.2.16",
"#angular/localize": "^10.0.5",
"#angular/material": "10.1.0",
"#angular/material-moment-adapter": "10.1.0",
"#angular/platform-browser": "10.0.5",
"#angular/platform-browser-dynamic": "10.0.5",
"#angular/platform-server": "^10.0.5",
"#angular/router": "10.0.5",
"#ng-bootstrap/ng-bootstrap": "^7.0.0",
"#ng-toolkit/universal": "^8.1.0",
"#nguniversal/express-engine": "^10.0.1",
"#types/jquery": "^3.5.1",
"#types/node": "^8.10.62",
"angular-in-memory-web-api": "^0.11.0",
"angular-ng-autocomplete": "^2.0.1",
"classlist.js": "^1.1.20150312",
"codelyzer": "^6.0.0",
"core-js": "2.6.9",
"crypto-js": "^3.3.0",
"express": "^4.15.2",
"firebase": "^7.17.1",
"hammerjs": "^2.0.8",
"jquery": "^3.5.1",
"localstorage-polyfill": "^1.0.1",
"moment": "2.24.0",
"ng2-slim-loading-bar": "^4.0.0",
"ng5-slider": "^1.1.14",
"ngx-order-pipe": "^2.0.4",
"ngx-pagination": "^3.2.1",
"ngx-spinner": "^10.0.1",
"rxjs": "^6.6.0",
"rxjs-compat": "^6.6.0",
"sweetalert2": "^8.19.0",
"tslib": "^1.13.0",
"web-animations-js": "^2.3.2",
"whatwg-fetch": "^3.2.0",
"zone.js": "0.10.3"
},
I just updated my project to Angular 10 and started facing this issue.
What i did was , wherever I had BehaviorSubject imports ,
i changed them from import { BehaviorSubject } from "rxjs/Rx"; to import { BehaviorSubject } from "rxjs";
This makes production build work without any error.
I got solution, use rxjs-tslint and migrate all rxjs syntax : https://www.npmjs.com/package/rxjs-tslint
I am able to solve this by using the build command as ng build --configuration=prod --aot= false --build-optimizer=false. Application is up and running for us now. But it's a work around only. We are trying to check few more ways without setting optimiser to false.Will update you.
I guess your question is solved,
I fixed it using ng build instead of ng build --prod. I am now investigating why the --prod command line compile my app differently
I guess your question is solved,
I fixed it using ng build instead of ng build --prod. I am now investigating why the --prod command line compile my app differently

How to setup storybook on an existing project

I've tried this. npx -p #storybook/cli sb init --type angular, on an existing project but fails with.
And dependancies look like :
"dependencies": {
"#angular/animations": "^9.0.6",
"#angular/cdk": "^9.1.2",
"#angular/common": "^9.0.6",
"#angular/compiler": "^9.0.6",
"#angular/core": "^9.0.6",
"#angular/forms": "^9.0.6",
"#angular/http": "^7.2.16",
"#angular/localize": "^9.0.6",
"#angular/material": "^9.1.2",
"#angular/platform-browser": "^9.0.6",
"#angular/platform-browser-dynamic": "^9.0.6",
"#angular/platform-server": "^9.0.6",
"#angular/router": "^9.0.6",
"#ng-bootstrap/ng-bootstrap": "^6.0.0",
"#nguniversal/express-engine": "^9.0.2",
"#nguniversal/module-map-ngfactory-loader": "^8.2.6",
"#swimlane/ngx-charts": "^13.0.2",
"#types/lodash": "^4.14.149",
"angular2-prettyjson": "^3.0.1",
"angularfire2": "^5.4.2",
"angularx-qrcode": "^2.1.1",
"archiver": "^3.1.1",
"body-scroll-lock": "^2.6.4",
"bootstrap": "^4.4.1",
"core-js": "^3.6.4",
"firebase": "^7.11.0",
"hammerjs": "^2.0.8",
"jquery": "^3.4.1",
"jquery-ui": "^1.12.1",
"localforage": "^1.7.3",
"lodash": "^4.17.15",
"marked": "^1.1.0",
"moment": "^2.24.0",
"open-graph": "^0.2.4",
"rxjs": "^6.5.4",
"scss": "^0.2.4",
"ts-loader": "^6.2.1",
"ts-transformer-keys": "^0.4.1",
"turndown": "^6.0.0",
"underscore.string": "^3.3.5",
"zip-local": "^0.3.4",
"zone.js": "^0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.900.6",
"#angular/cli": "^9.0.6",
"#angular/compiler-cli": "^9.0.6",
"#angular/language-service": "^9.0.6",
"#babel/core": "^7.10.4",
"#storybook/addon-actions": "^5.3.19",
"#storybook/addon-links": "^5.3.19",
"#storybook/addon-notes": "^5.3.19",
"#storybook/addons": "^5.3.19",
"#storybook/angular": "^5.3.19",
"#types/bootstrap": "^4.3.1",
"#types/jasmine": "^3.5.9",
"#types/jasminewd2": "^2.0.8",
"#types/jquery": "^3.3.33",
"#types/node": "^13.9.1",
"babel-loader": "^8.1.0",
"browser-sync": "^2.26.7",
"codelyzer": "~5.2.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "~3.1.1",
"karma-jasmine-html-reporter": "^1.5.2",
"node-sass": "^4.13.1",
"protractor": "~5.4.3",
"ts-node": "~8.6.2",
"tslint": "^6.1.1",
"typescript": "~3.7.5"
}
}
I've also tried removing node modules and installing again, it just comes back here.
it looks like there are 2 '}'s at the end, is that intentional? if not try removing one of them.

app.auth is not a function after upgrade to angular8

I've recently upgraded my Angular project to version 8, but I'm struggling to upgrade angularfire2 to version 5.2.1 which supports Angular 8. I constantly getting the error:
TypeError: app.auth is not a function...
I've already tried to uninstall and reinstall angularfire2. I also cleared the entire node modules folder and reinstalled all the packages.
This is what the dependencies look like:
"dependencies": {
"#angular/pwa": "^0.13.0",
"core-js": "^2.6.0",
"firebase-admin": "^7.0.0",
"firebase-functions": "^2.2.0",
"material-bottom-nav": "^1.0.6",
"ng": "0.0.0-rc6",
"ngx-infinite-scroll": "^7.0.1",
"time-ago-pipe": "^1.3.2",
"ts-deepcopy": "^0.1.4",
"tslib": "^1.9.0",
"update": "^0.7.4",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.29"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.800.6",
"#angular/animations": "^8.0.3",
"#angular/cdk": "^8.0.1",
"#angular/cli": "^8.0.6",
"#angular/common": "^8.0.3",
"#angular/compiler": "^8.0.3",
"#angular/compiler-cli": "^8.0.3",
"#angular/core": "^8.0.3",
"#angular/fire": "^5.2.1",
"#angular/flex-layout": "^8.0.0-beta.26",
"#angular/forms": "^8.0.3",
"#angular/language-service": "^8.0.3",
"#angular/material": "^8.0.1",
"#angular/platform-browser": "^8.0.3",
"#angular/platform-browser-dynamic": "^8.0.3",
"#angular/platform-server": "^8.0.3",
"#angular/router": "^8.0.3",
"#angular/service-worker": "^8.0.3",
"#types/core-js": "^0.9.46",
"#types/jasmine": "2.8.7",
"#types/lodash": "^4.14.126",
"#types/node": "^10.12.30",
"codelyzer": "~4.3.0",
"firebase": "^6.3.1",
"hammerjs": "^2.0.8",
"i": "^0.3.5",
"jasmine-core": "~3.1.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.5",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.4.0",
"lodash": "^4.17.15",
"npm": "^6.9.0",
"protractor": "~5.3.2",
"rxjs": "^6.5.2",
"ts-node": "~6.0.5",
"tslint": "~5.10.0",
"typescript": "^3.4.5"
},
Did someone already upgrade to angularfire2 version 5.2.1 and can help me out with this?
Uninstalling the firebase-admin library from the project solved the issue.
npm uninstall firebase-admin

Angular 7 post-upgrade styling issue

We've upgraded our application from Angular 5.2 to 7.2 and the styling got messed up. The spacing between some elements (for example: icons and text) has changed, disappeared or decreased.
Have any of you encountered an issue like this after upgrading an Angular application or the following packages?
I already reverted back every possible package to their staging versions, but it didn't solve the problem.
I have no idea where to start the troubleshooting to find the source of the problem. The styling and the HTML haven't been changed.
We updated:
Bootstrap: from 4.1.0 to 4.3.1
#ng-bootstrap/ng-bootstrap: from 1.1.2 to 4.0.0
ngx-bootstrap: from 2.0.5 to 4.0.0
The styling is global from the angular.json:
Where we import the used Bootstrap components:
The package.json look like this:
{
"private": true,
"dependencies": {
"#angular/animations": "7.2.11",
"#angular/common": "7.2.11",
"#angular/compiler": "7.2.11",
"#angular/core": "7.2.11",
"#angular/forms": "7.2.11",
"#angular/http": "7.2.11",
"#angular/platform-browser": "7.2.11",
"#angular/platform-browser-dynamic": "7.2.11",
"#angular/platform-server": "7.2.11",
"#angular/router": "7.2.11",
"#fortawesome/angular-fontawesome": "0.3.0",
"#fortawesome/fontawesome-svg-core": "1.2.12",
"#fortawesome/free-solid-svg-icons": "5.6.3",
"#ng-bootstrap/ng-bootstrap": "4.0.0",
"#nguniversal/express-engine": "7.1.1",
"#ngx-translate/core": "11.0.1",
"#ngx-translate/http-loader": "4.0.0",
"acorn": "6.1.1",
"angular2-image-zoom": "1.2.1",
"bootstrap": "4.3.1",
"braintree-web-drop-in": "1.16.0",
"core-js": "2.6.5",
"file-saver": "2.0.1",
"font-awesome": "4.7.0",
"htmllint": "0.7.3",
"intl": "1.2.5",
"jquery": "3.3.1",
"ng-jhipster": "0.9.3",
"ng-recaptcha": "4.2.1",
"ng2-order-pipe": "0.1.5",
"ngx-bootstrap": "4.0.0",
"ngx-color-picker": "7.4.0",
"ngx-cookie": "4.1.2",
"ngx-webstorage": "3.0.2",
"popper.js": "1.14.7",
"print-js": "1.0.54",
"rxjs": "6.4.0",
"rxjs-compat": "6.4.0",
"tslib": "1.9.3",
"zone.js": "0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "0.13.7",
"#angular/cli": "7.3.7",
"#angular/compiler-cli": "7.2.11",
"#angular/language-service": "7.2.11",
"#types/file-saver": "2.0.0",
"#types/hammerjs": "2.0.36",
"#types/jasmine": "3.3.12",
"#types/jasminewd2": "2.0.6",
"#types/node": "11.12.0",
"codelyzer": "5.0.0",
"jasmine-core": "3.3.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "2.0.0",
"karma-coverage-istanbul-reporter": "2.0.5",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.0",
"node-sass": "4.11.0",
"protractor": "6.0.0",
"sort-json": "2.0.0",
"ts-node": "8.0.3",
"tslint": "5.14.0",
"typescript": "3.2.4"
}
}
I believe from Angular 6 the preserveWhitespace option is false by default. To turn it on again globally you can add an option in tsconfig.app.json:
"angularCompilerOptions": {
"preserveWhitespaces": true
}
Or you can use the directive ngPreserveWhitspaces on any elements where you need the whitespace to be preserved.
See here for some (quite hidden) documentation on it.

Firebase has no exported member promise

It was working fine without any issues. I tried to update the "#ionic-native/core": "3.12.1" to latest and then rolled back the version after that i am getting this error. Can somebody please let me know if there is any version mismatch ? Thank you.
"dependencies": {
"#angular/common": "4.1.3",
"#angular/compiler": "4.1.3",
"#angular/compiler-cli": "4.1.3",
"#angular/core": "4.1.3",
"#angular/forms": "4.1.3",
"#angular/http": "4.1.3",
"#angular/platform-browser": "4.1.3",
"#angular/platform-browser-dynamic": "4.1.3",
"#ionic-native/barcode-scanner": "^4.4.0",
"#ionic-native/camera": "^4.4.2",
"#ionic-native/core": "3.12.1",
"#ionic-native/device": "^4.6.0",
"#ionic-native/fcm": "^4.6.0",
"#ionic-native/geolocation": "^4.4.2",
"#ionic-native/google-plus": "^4.6.0",
"#ionic-native/photo-library": "^4.4.2",
"#ionic-native/printer": "^4.6.0",
"#ionic-native/push": "^4.6.0",
"#ionic-native/splash-screen": "3.12.1",
"#ionic-native/status-bar": "3.12.1",
"#ionic/storage": "2.0.1",
"angular2-signaturepad": "^2.8.0",
"angularfire2": "^4.0.0-rc0",
"chart.js": "^2.7.1",
"cordova-android": "^7.0.0",
"cordova-ios": "^4.5.4",
"cordova-plugin-add-swift-support": "^1.6.0",
"cordova-plugin-camera": "^3.0.0",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-fcm": "^2.1.2",
"cordova-plugin-file": "^4.3.2",
"cordova-plugin-geolocation": "^3.0.0",
"cordova-plugin-googleplus": "^5.2.1",
"cordova-plugin-photo-library": "^2.1.0",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"firebase": "^4.6.2",
"font-awesome": "4.7.0",
"ionic-angular": "3.6.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"phonegap-plugin-barcodescanner": "^7.0.0",
"phonegap-plugin-push": "^2.2.2",
"rxjs": "5.4.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.12"
},
"devDependencies": {
"#angular/cli": "^1.2.7",
"#ionic/app-scripts": "2.1.3",
"#ionic/cli-plugin-cordova": "1.6.2",
"ionic": "3.7.0",
"typescript": "2.3.4"
},
Downgraded my firebase version to 3.9.* it worked.

Resources