I want to use angular in my asp.net mvc website .
Every thing works fine in home page (localhost:xxxx) for loading carousel, but when i redirect to admin page(localhost:xxxx/admin), i get below error on browser console
> Error: [$injector:modulerr] http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=MollahajiModule&p1=[$injector:nomod] http://errors.angularjs.org/1.5.8/$injector/nomod?p0=MollahajiModule
N/<#http://localhost:25150/Scripts/angular.min.js:6:412
ke/</</<#http://localhost:25150/Scripts/angular.min.js:25:99
b#http://localhost:25150/Scripts/angular.min.js:24:142
ke/</<#http://localhost:25150/Scripts/angular.min.js:24:385
g/<#http://localhost:25150/Scripts/angular.min.js:39:471
q#http://localhost:25150/Scripts/angular.min.js:7:353
g#http://localhost:25150/Scripts/angular.min.js:39:319
cb#http://localhost:25150/Scripts/angular.min.js:43:336
Bc/c#http://localhost:25150/Scripts/angular.min.js:20:390
Bc#http://localhost:25150/Scripts/angular.min.js:21:179
fe#http://localhost:25150/Scripts/angular.min.js:20:1
#http://localhost:25150/Scripts/angular.min.js:317:386
jQuery.Callbacks/fire#http://localhost:25150/Scripts/jquery-1.10.2.js:3062:10
jQuery.Callbacks/self.fireWith#http://localhost:25150/Scripts/jquery-1.10.2.js:3174:7
.ready#http://localhost:25150/Scripts/jquery-1.10.2.js:447:3
completed#http://localhost:25150/Scripts/jquery-1.10.2.js:118:4
I've also tried route, but got no result
var Application = angular.module('AdminModule', ["ngRoute"]);
Application.config(['$routeProvider','$locationProvider',function ($routeProvider, $locationProvider) {
$routeProvider
.when('/admin', {
templateUrl: '/Views/Admin/Index.html',
controller: 'HomeCarouselController'
});
$locationProvider.html5Mode(true);
}]);
Related
I am implementing oauth2 login with AngularJS 1.6.x
My index.html is located at my domain eg. http://mydomain/app/
When user click a button on the page, it will redirect the user to a oauth page for login using below code snippet
window.location.replace("https://xxxx/oauth2/xxx");
The user will then be redirected to my app again at http://mydomain/app/?code=xxxxx
The problem I am encountering is that the when('/:code', { is not triggered and the loginCtrl is not fired in which I would like to capture the oauth authorization code. Anything I have done wrong here? Thanks a lot.
Below is my app.js file
var app = angular.module("myApp", ['ngResource', 'ngRoute', 'ngCookies']);
// Routing
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'pages/main.html',
controller : 'mainCtrl'
})
.when('/:code', {
templateUrl : 'pages/login.html',
controller : 'loginCtrl'
})
});
I am moving my mvc application in angularjs.
I have different areas in the application. I want to move between areas using MVC routing. And I want to use Angular routing inside each area.
So in my server I have default routing configuration... and in my angular I have the following configuration:
.config(function ($routeProvider, $locationProvider) {
var viewBase = '/Views/AngularTemplates/';
$routeProvider
.when('/Servizi/Cpe/New', {
templateUrl: viewBase + 'Cpes/insert.html',
controller: 'cpesController'
})
.when('/Servizi/Cpe', {
templateUrl: viewBase + 'Cpes/list.html',
controller: 'cpesController'
});
$locationProvider.html5Mode(true);
})
Servizi is my area and Cpe is the controller in the area... When I move from /Servizi/Cpe to /Servizi/Cpe/New it works because it is managed by angular.
But I cannot move from /Home to /Servizi because it's managed by MVC routing.
How can do that ?
A very quick solution to move between 'areas' would be:
window.location.href = "myAreaPath/mypage.asp";
Try it and tell us if work for you ;)
I am creating single page application using node,express and angular js. I am not getting that how to manage routes in both angular and express(node).
Please help me and If possible give some example code or link.
If you wanna create a single page application you need to use the router of angular for navigate in your app without reload, but in generally you need data from server, to organise this data you need a route on node.
This is a example of ngRoute
http://plnkr.co/edit/L4Hxf7KiiVuouPWRv4pl
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
template: 'hello'
})
.when("/red", {
template: 'hi'
})
.when("/green", {
templateUrl: 'hello.html'
})
.when("/blue", {
templateUrl: 'blue.html'
});
});
example of node route
http://expressjs.com/en/guide/routing.html
There is no a clear solution for my below question in stackoverflow, i have searched for many but its not suitable
note: am not using GRUNT
Actually am developing a application using Node and Angular,
while using angular-route to route a page from application its working fine, but reloading browser shows me Cannot GET /secure/home
app.js
var myApp = angular.module('Whizzrd', ['ngRoute']).
config(['$routeProvider', '$locationProvider', '$httpProvider', function($routeProvider, $locationProvider, $httpProvider) {
$routeProvider.
when('/secure/home', {
templateUrl: '/pages/static/home.html',
controller: 'homeController'
});
$locationProvider.html5Mode({enabled: true, requireBase: false});
}]);
moving through home.html through application is working fine, but while reloading the page using browser am getting error as
Cannot GET /secure/home
Am stuck with this for more than 2 days, Help will be appreciated really
I am trying to modify the url of my angularjs app . Initially my urls were http:localhost:8080/a/web/app/index.html#/ and http:localhost:8080/a/web/app/index.html#/next
when I inserted the following code to my app.js
var App =angular.module('App', [
'ngCookies',
'ngResource',
'ngRoute',
])
.config(function ($routeProvider,$locationProvider) {
$routeProvider
.when('/', {
templateUrl: '/a/web/app/views/main.html',
controller: 'ctrl_main'
})
.when('/next', {
templateUrl: '/a/web/app/views/next.html',
controller: 'ctrl_next'
});
$locationProvider.html5Mode(true);
});
My new urls became http:localhost:8080 and
http:localhost:8080/next .
My problem is when I tried to reload the page at http:localhost:8080/next , 404 Not Found error is coming
That's expected with html5 mode. The browser, if you ask it to reload, will send a request to the URL it has in its location bar.
So you need to configure the server to actually send back the index.html page for all the bookmarkable URLs you use in the angular application. The whole page will reload, the angular app will restart, the $route service will restart, and will invoke the controller and display the partial configured for the URL.
I know the answer is a bit outdated, but in my case adding <base> attribute to index.html helped, for example:
<base href="/a/web/app/">