I want to add fusioncharts to my angularjs app. I have followed this link:
http://www.fusioncharts.com/blog/2015/03/angular-fusioncharts/
But as soon as I add ng-fusioncharts to my app.js as:
var app = angular.module('myApp',['ngRoute', 'firebase','ng-fusioncharts']);
app.config(function($routeProvider){
$routeProvider
.when('/', {
controller: 'OrgListController',
templateUrl: 'views/organization/list.html'
})
.when('/add_org', {
controller: 'OrgAddController',
templateUrl: 'views/organization/org_add.html'
})
.when('/edit_org/:id', {
controller: 'OrgEditController',
templateUrl: 'views/organization/org_edit.html'
})
.when('/add_access_point', {
controller: 'AccessPointAdd',
templateUrl: 'views/access_points/access_add.html'
})
.when('/edit_access_point/:id', {
controller: 'AccessPointEdit',
templateUrl: 'views/access_points/access_edit.html'
})
.when('/add_user', {
controller: 'UserAdd',
templateUrl: 'views/users/user_add.html'
})
.when('/edit_user/:id', {
controller: 'UserEdit',
templateUrl: 'views/users/user_edit.html'
})
.otherwise({
redirectTo: '/'
});
});
Nothing gets displayed and my whole project doesn't work. Viewing in console says :
error: inject modulerr.................
Somebody please suggest how to add multiple dependencies in one module?
You need to have fusion-chart.js inorder to inject ng-fusioncharts
var app = angular.module('HelloApp', ["ng-fusioncharts"])
DEMO
Related
I have web application where I need to load a template with different parameters like.
.when('/form/:ProjectID/:FormID', {
templateUrl: 'partials/Form.ashx?fid=' + FormID,
controller: 'FormController'
})
I am not able to get the above code working. Can someone tell me how I can fix this issue? I am new to AngularJS and not an expert.
This is the full code.
var app = angular.module('MyApp', ['ui.grid', 'ngSanitize', 'angularTrix', 'ui.codemirror', 'ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/home', {
templateUrl: 'partials/Home.ashx',
controller: 'HomeController'
})
.when('/project/:ProjectID', {
templateUrl: 'partials/Projects.ashx',
controller: 'ProjectController'
})
.when('/form/:ProjectID/:FormID', {
templateUrl: 'partials/Form.ashx?fid=1',
controller: 'FormController'
})
.otherwise({ redirectTo: '/home' });
});
We can use $stateParams and templateProvider to load dynamic templateurl
.state('general', {
url: '/{type}',
//templateUrl: 'pages/home.html',
templateProvider: ['$stateParams', '$templateRequest',
function($stateParams, $templateRequest)
{
var tplName = "pages/" + $stateParams.type + ".html";
return $templateRequest(tplName);
}
],
// general controller instead of home
//controller: 'homeController',
controller: 'generalController',
controllerAs: 'ctrl'
My team and I are developing a muli-page MVC application using AngularJS and DotNetNuke. In our routes.js, we point to specific controllers and templates.
Here is our routes.js code:
angular.module('SurveyWrangler').config(function ($routeProvider) {
$routeProvider
.when('', {
redirectTo: '/surveys'
})
.when('/', {
redirectTo: '/surveys'
})
.when('#', {
redirectTo: '/surveys'
})
.when('/surveys', {
controller: "SurveyIndexController",
templateUrl: "/DesktopModules/HealthPlanSurvey/templates/survey/index.html"
})
.when('/surveys/new', {
templateUrl: "/DesktopModules/HealthPlanSurvey/templates/survey/create.html",
controller: "SurveyCreateController"
})
.when('/surveys/:id', {
templateUrl: "/DesktopModules/HealthPlanSurvey/templates/survey/show.html",
controller: "SurveyShowController"
})
.when('/surveys/:id/edit', {
templateUrl: "/DesktopModules/HealthPlanSurvey/templates/survey/edit.html",
controller: "SurveyEditController"
})
.when('/surveys/:id/carryforward', {
templateUrl: "/DesktopModules/HealthPlanSurvey/templates/survey/carryForward.html",
controller: "SurveyCarryForwardController"
})
});
The link for the app is www.OURWEBSITE.com/Surveys#/surveys, but the URL changes to just ~/Surveys# when you click the link in the menu bar.
The menu bar is rendered out by DNN. This is baffling to me because from what I can tell from the code, I should be redirected back to ~/Survey#/surveys. Instead, I get a blank screen. Also, no errors in the browser console.
Thanks for any help!
I'm a newbie with AngularJS and I got a problem that I think that's it's can be configurable in my routeProvider.
I have this route
angular
.module('app', ['ngRoute', 'ngStorage'])
.config(['$routeProvider', function ($routeProvider) {
debugger;
$routeProvider.when('/:module/:task/:id/:menu/:action', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module/:task/:id/:menu', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module/:task/:id', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module/:task', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/', { templateUrl: 'app/start.html' });
$routeProvider.otherwise({ redirectTo: '/' });
}
]);
the problem: When I just type http://localhost:53379 I'm redirected to http://localhost:53379/#/ . Where come from the /#/ ?
By default, AngularJS will route URLs with a hashtag.
For example:
http://domain.com/#/home
http://domain.com/#/about
You can very easy remove the hashtag from the URL by setting html5Mode to true in your config:
$locationProvider.html5Mode(true);
so in your code it will be:
angular
.module('app', ['ngRoute', 'ngStorage'])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
debugger;
$routeProvider.when('/:module/:task/:id/:menu/:action', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module/:task/:id/:menu', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module/:task/:id', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module/:task', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/:module', { templateUrl: 'app/blank.html', controller: PagesCtrl });
$routeProvider.when('/', { templateUrl: 'app/start.html' });
$routeProvider.otherwise({ redirectTo: '/' });
$locationProvider.html5Mode(true);
}
]);
Just after that you have to make sure that your backed will redirect all requests to your home page if you are doing "Single Page App"
Angular adds it by default. I don't know it this is the main reason, but one reason is that the routing doesn't work in older versions of IE. I had this problem in one angularjs app that didn't work in IE9 because of this reason.
Anyways, to remove the hashtag simply add $locationProvider.html5Mode(true); after your routing-declarations.
You can read more about it here: http://scotch.io/quick-tips/js/angular/pretty-urls-in-angularjs-removing-the-hashtag
This /#/ is used to create a single page application. the # is used to prevent that the page is completely reloaded. Angular then catches the new URL and loads the correct controller and partials depending on your route configuration.
Since HTML5 it is possible to remove this behavior with $location.html5Mode(true).
Source:
AngularJS documentation
i am learning how to use angularjs routing and templating, and i have come across a problem. I have added the gem in Gemfile, added //= require angular-rails-templates in application.js, and added the dependancy in my main angular.module
angular.module('authentication', ['authenticationModule','ngRoute','templates'])
.config(['$routeProvider',function($provider){
$provider
.when('/sign_in', { templateUrl: '/assets/signin.html', controller: 'redirectCtrl'})
.when('/sign_up', { templateUrl: 'templates/signup.html.erb', controller: 'redirectCtrl1'})
.controller('redirectCtrl', function($location) {
$location.path('/sign_in')
})
.controller('redirectCtrl1', function($location) {
$location.path('/sign_up')
})
My signin.html is located in /assets/templates/signin.html
When i try to load the page, i dont get the rendered page, but instead i get this
window.AngularRailsTemplates || (window.AngularRailsTemplates = angular.module("templates", [])); window.AngularRailsTemplates.run(["$templateCache",function($templateCache) { $templateCache.put("signin.html", "\u003cdiv ng-controller=\"authenticationCtrl\"\u003e\n\t\u003cdiv\u003e\n\t \u003ch1\u003eLogin\u003c/h1\u003e\n\t\u003c/div\u003e\n\t\u003cdiv\u003e\n\t\t\u003cdiv\u003e\n\t\t \u003cdiv\u003eEmail: \u003cinput ng-model=\"email\" type=\"email\" /\u003e\u003c/div\u003e\n\t\t \u003cdiv\u003ePassword: \u003cinput type=\"password\" ng-model=\"password\" /\u003e\u003c/div\u003e\n\n\t\t \u003cbutton ng-click=\"login()\" \u003eLogin\u003c/button\u003e\n\t\t\u003c/div\u003e\n\t\u003c/div\u003e\t\t\t\t\n\u003c/div\u003e\n"); }]);
Any solution to my problem?
Thanks in advance
Update 1:
Ok,so i have changed the following things,
angular.module('authentication', ['authenticationModule','ngRoute','templates'])
.config(['$routeProvider',function($provider){
$provider
.when('/sign_in', { templateUrl: 'assets/signin.html', controller: 'redirectCtrl'})
.when('/sign_up', { templateUrl: 'assets/signup.html', controller: 'redirectCtrl1'})
}])
.controller('redirectCtrl', function($location) {
// $location.path('/sign_in')
})
.controller('redirectCtrl1', function($location) {
// $location.path('/sign_up')
})
And here is what i get now, the template loads but with some extra stuff that i dont need
http://postimg.org/image/iuhy9dflj/
remove the / before assets, and point to the templates folder
angular.module('authentication', ['authenticationModule','ngRoute','templates'])
.config(['$routeProvider',function($provider){
$provider
.when('/sign_in', { templateUrl: 'assets/templates/signin.html', controller: 'redirectCtrl'})
.when('/sign_up', { templateUrl: 'templates/signup.html.erb', controller: 'redirectCtrl1'})
.controller('redirectCtrl', function($location) {
$location.path('/sign_in')
})
.controller('redirectCtrl1', function($location) {
$location.path('/sign_up')
})
I am using MVC Web API and Angular JS
When i am giving single routeProvider, then its working after adding one more routeProvider its not working....
My Code Is:
var phoneModelsApp = angular.module('phoneModelsApp', ['ngRoute']);
phoneModelsApp.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.when('/phonelist', {
templateUrl: 'partials/Test1.html',
controller: 'phoneListCtrl'
}).
$routeProvider.when('/phonelist1', {
templateUrl: 'partials/Test2.html',
controller: 'phoneListCtrl'
}).
otherwise({
redirectTo: '/phonelist'
});
}]);
You need to add to in your urls "#" or adding in your configuration:
$locationProvider.html5Mode(true);
In order to remove the # in Angular you need to make an small change in your configuration:
You need to add:
$locationProvider.html5Mode(true);
This is the whole version:
myApp.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/page1', { template: 'page1.html', controller: 'Page1Ctrl' })
.when('/page2', { template: 'page2.html', controller: 'Page2Ctrl' })
});