I have an ng-click on a button to open a modal. When I try to open it, the design open a modal but with the page where I open it. Why is it possible?
$scope.EditPlayer = function (gid) {
var modalIstance = $uibModal.open({
templateUrl: "/Modal/modalUser.html",
controller: 'UserEditController'
});
}
I think that my routing create some problem...
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', { controller: 'MainController', templateUrl: 'Views/home.html' })
.when('/index', { controller: 'MainController', templateUrl: 'Views/home.html' })
.when('/index.html', { controller: 'MainController', templateUrl: 'Views/home.html' })
.when('/userlist', { controller: 'UserListController', templateUrl: 'Views/userlist.html' })
.when('/useradd', { controller: 'UserAddController', templateUrl: 'Views/useradd.html' })
$locationProvider.html5Mode(true);
})
Anyone can help me? Thanks
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 AngularJs routing always redirects to the home page and always calls HomeController rather than redirecting to /VechileRegistration/Index, VechileRegistration/VechileInward
$routeProvider
.when('/', {
controller: 'HomeController',
templateUrl: '/home/home.view.html',
controllerAs: 'vm'
})
.when('/VechileRegistration/Index', {
controller: 'HomeController2',
templateUrl: '/home/home.view2.html',
controllerAs: 'vm'
})
.when('/VechileRegistration/VechileInward', {
controller: 'VehicleInwardController',
templateUrl: '/home/VehicleInward.view.html',
controllerAs: 'vm'
})
.otherwise({
redirectTo: '/login'
});
How can I redirect to the right place and call the appropriate controller?
var app = angular.module('ngRoutingDemo', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/login.html',
controller: 'loginController'
}).when('/student/:username', {
templateUrl: '/student.html',
controller: 'studentController'
}).otherwise({
redirectTo: "/"
});
app.controller("loginController", function ($scope, $location) {
$scope.authenticate = function (username) {
// write authentication code here..
$location.path('/student/' + username)
};
});
app.controller("studentController", function ($scope, $routeParams) {
$scope.username = $routeParams.username;
});
});
my code its something like this:
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
controller: 'HomeController',
templateUrl: 'views/home.html'
})
.when('/login', {
controller: 'LoginController',
templateUrl: 'views/login.html'
})
.otherwise({
redirectTo: '/'
});
});
But I wonder if it could be something like this:
...
.when('/login' OR '/' OR '/SOMETHING', {
controller: 'LoginController',
templateUrl: 'views/login.html'
})
...
I already read doc of when function and a have see this question too, but unfortunately I have not be able to find a conclusive answer.
Can when function of routeProvider take multiple url paths?
Thank you in advance.
Your code seems to be fine.Can you just guide me which error you are getting?
In order to reuse the data you can simply:
app.config(function ($routeProvider) {
loginData = {
controller: 'LoginController',
templateUrl: 'views/login.html'
};
$routeProvider
.when('/', loginData)
.when('/login', loginData)
…
.otherwise({
redirectTo: '/'
});
});
I have a problem with my $urlRouterProvider.otherwise();
When emulated on android, the app launches on the artists state and not the welcome.
I don't see where the problem might come from.
app.config(['$stateProvider', '$urlRouterProvider', '$ionicConfigProvider', '$sceDelegateProvider', function($stateProvider, $urlRouterProvider, $ionicConfigProvider, $sceDelegateProvider){
$stateProvider.state('welcome', {
url: '/welcome',
templateUrl: 'templates/welcome.html',
controller: 'WelcomeCtrl'
})
.state('user',{
url:'/user',
templateUrl: 'templates/user.html',
controller: 'UserCtrl'
})
.state('settings',{
url:'/settings',
templateUrl: 'templates/settings.html'
// controller: 'SettingsCtrl'
})
.state('artists',{
url:'/artists',
templateUrl: 'templates/artists.html',
controller: 'ArtistsCtrl'
})
.state('artist',{
url:'/artists/:artistId',
templateUrl: 'templates/artist.html',
controller: 'ArtistCtrl'
})
.state('search',{
url:'/search',
templateUrl: 'templates/search.html',
controller: 'SearchCtrl'
});
$urlRouterProvider.otherwise('/welcome');
}]);
thanks for any help !
try using
$stateProvider
.state("welcome", { url : '/welcome'})
Is it possible to have a route param in the base url with ngRoute?
<base href="/some/resource/path/:myParameter/" />
together with:
angular.module('myApp', ['ngRoute'])
.config(["$routeProvider", "$locationProvider", function ($routeProvider, $locationProvider) {
$routeProvider
.when('/first', {
templateUrl: 'template.html',
controller: 'mainController'
})
.when('/second', {
templateUrl: 'template.html',
controller: 'mainController'
})
.when('/third', {
templateUrl: 'template.html',
controller: 'someController'
})
.when('/forth', {
templateUrl: 'template.html',
controller: 'someController'
})
.otherwise({
redirectTo: '/first'
});
$locationProvider.html5Mode(true);
}]);
to get routes of:
/some/resource/path/:myParameter/first
/some/resource/path/:myParameter/second
/some/resource/path/:myParameter/third
/some/resource/path/:myParameter/forth