Can not find namespace 'angular' - angularjs

I have an hybrid angular app with Angularjs 1.5.8 and angular 5.2.9. I had followed the steps from the Upgrading from AngularJS to Angular. It is working perfectly fine.
However, after I upgrade angular 5.2.9 to angular 6.0.1, I am getting error during ng serve.
error TS2503: Cannot find namespace 'angular'
As mentioned in the Upgrading from AngularJS to Angular I have declared 'angular'
declare var angular: angular.IAngularStatic;
While upgrading angular from 5.2.9 to 6.0.1, I followed the steps from Angular Update Guide - 5.2 -> 6.0 for Advanced Apps
How can I resolve this problem?

try npm install --save-dev #types/angular
if not try the following:
you need to add "angular" types to tsconfig.json
...
"types": [
"angular"
],

Related

Bower - multiple versions of angular

I'm working on an angular app that uses bower for dependency management. At the moment I'm getting the following error in my browser console:
Uncaught TypeError: angular.module(...).info is not a function
From researching this a bit, it seems that I likely have two different versions of angular in use and that's the cause of the error. However, I've used bower list and it looks like angular and all of the packages that list angular as a dependency are using the same version: 1.4.14
In the bower.json file, angular is listed as: "angular": "~1.4.9" under both dependencies and resolutions.
How can I track down where another version of angular is being used? Or could there be something else causing this issue?
Note: this app runs fine on another computer, which is why I'm convinced it's a version issue.

Inject ngMaterial using webpack, angular fullstack generator

I want to build a web application and I have started building this by using the angular fullstack generator. This generator uses webpack and this is the first time I am using webpack.
I have been trying to add the ngMaterial dependency by installing it with:
npm install angular-material --save
I have added the dependency in the config.entry.vendor from the webpack.make.js file but when I tried to import the ngMaterial i received the following error:
ERROR in ./client/app/app.js
Module not found: Error: Cannot resolve module 'ngMaterial' in path\client\app
# ./client/app/app.js 21:18-39
How can I inject a dependency with webpack?
I assume you pointed incorrect dependency name in webpack configuration: ngMaterial instead of angular-material.
ngMaterial is angularjs module name, you point it as a dependency in your angular app module, like this:
angular.module('app', ['ngMaterial'])
But in webpack dependencies you have to point node.js module name, which is angular-material (it is located in node_modules folder after you install it via npm install command)
EDIT:
If needed in your app.js you also have to import that module via import 'angular-material' or require('angular-material'). But if you include this dependency in separate vendor.js file (via webpack), than you shouldn't ever include this module in your app.js, cause it will upload to the page in vendor.js. You'll include it 2 times in your project if you do so.

Cannot find module 'angular' inside angular 2 project

I'm using angular-cli, typescript, trying to downgrade angular2 component, so it will work inside angular 1.5 project but the module is not recognize. What I'm missing?
// Angular 1 Vendor Import
import * as angular from 'angular';
This was solved by:
npm install #types/angular

Using angular from both atmosphere and npm gives warning

Using Meteor 1.3.2.4 I do:
meteor create myapp
cd myapp
meteor npm install --save angular
meteor add angularjs:angular
and in main.js add as first line
import angular from 'angular';
This gives me
WARNING: Tried to load angular more than once.
in the browser console.
I guess this is because angular packages from both npm and atmosphere are added, but I do not know how to circumvent this if I need an atmosphere package that depends on angularjs:angular and also want to to use angular from npm (for example when using angular-meteor). More specifically I want to use the package angular-leaflet-directive in a meteor/angular app. Any suggestions ?
I asked the same question here.
The package author needs to follow those instructions here to make his package work on both Meteor 1.3 and Meteor 1.2 and earlier.
Maybe you could submit a pull request for him and until he will merge it, you could publish to Atmosphere under your own user.
Also, you could just bring angular-leaflet-directive from npm!

Mean.js - angular is not defined

I'm just trying to run mean.js using grunt. Just did the installation steps in http://meanjs.org. But when loaded in localhost, console is showing error
Uncaught ReferenceError: angular is not defined
Can any one help how to resolve this problem?
It sounds like angular is not included on the page.
When the install process is over, npm will initiate a bower install command to install all the front-end modules needed (including angular) for the application
You can run bower manually using
bower install --config.interactive=false
make sure that angular appears in the public/lib folder and included on the page.

Resources