Menu
  • HOME
  • TAGS

Set focus on text input in angular template/route/form

javascript,html,angularjs,focus,angular-routing

If you know which input you need the focus on, you can just add this to one of them. <input type="text" ... autofocus/> If you need to change which one gets the focus depending on some other variable, then you may need to add a custom directive to your form...

UI-Router and optional parametr in subroute without reloading controller

javascript,angularjs,angular-ui-router,angular-routing

There is a working plunker The point is - parameter is declared on child state, so only child state controller can access it Child state has controller: .state('messages', { url: '/messages', templateUrl: 'templates/messages/list.html', controller: 'MessagesCtrl' }) .state('messages.root', { url: '/:id', templateUrl: 'tpl.html', controller: 'ChildCtrl', }) Child controller has access to...

AngularJS routing, pass id with ui-sref while displaying a slug and not the id in the url

javascript,angularjs,angularjs-routing,angular-routing

.state('user', { url: '/:slug', params: { id: { value: -1 } }, I have used the above so the ids where not passed in the url. ...

Angular.js Error: $injector:modulerr

angularjs,angular-routing

You need to add ngRoute module in your app and also the script reference of the angular-route.min.js write after the angular.js, Also you need to add bsm.js and allBooks.js in your html after above two mentioned file has loaded. Code var app = angular.module('booksInventoryApp', [ 'booksInventoryApp.bsm', 'booksInventoryApp.allBooks', 'ngRoute' ]); Note...

Angular convert date before referring to it in routing

angularjs,angular-routing

i think you should use the date filter https://docs.angularjs.org/api/ng/filter/date or create your own : app.filter('getUtcDate', [ function() { return function(input) { return input.toUTCString(); }; } ]); and then you could do : <button type="submit" ui-sref="inventory({ expdate: expdate|getUtcDate })" class="btn btn-primary">Add</button> Edit : could you simply use : <button type="submit" ui-sref="inventory({...

AngularJS - link model to search string without watching

angularjs,angular-routing

You could try this, in your controller do this: .controller('testCtr', function($location){ this.search = { text:'', fn: $location.search.bind($location, 'text'); }; }) And then in your view do this: <div ng-controller="testCtr as vm"> <input type="text" ng-model="vm.search.text" ng-change="vm.search.fn(vm.search.text)"/> </div> ...

AngularJS ng-view not showing view

javascript,html,angularjs,angularjs-directive,angular-routing

I've solved the issue by changing the <ng-include> tag with an <div ng-include="srctoview"> tag. If anyone is having this issue i'd recommend doing this, or doing it like in this answer using a controller Thanks to @Sourabh- for leading me to an answer....

Template not loading in Angular route

javascript,angularjs,angular-routing

It's rather unclear how you've set up things? Is the HTML your index or is that your home.html? Secondly you already declare the controllers of your pages to be appController, no need to define that with the ng-controller directive anymore. Apart from that you're loading the same template on each...

AngularJS and GitHub Pages - loading templates issue

angularjs,github-pages,angular-routing

This is happening because angular is expecting that url to be relative to the root of the domain, not to the location of your app. In other words, it is expecting it to be relative to moroshko.github.io not moroshko.github.io/seekdeck. You can solve this easily by adding a base element to...

How send send parameter for $routeProvider in angularJS

angularjs,angular-routing

templateUrl can be used as a function if you need to work some magic on the url. It accepts 1 parameter which takes in the current url. Looking at your example, there aren't any parameters in /relatedStyle; but if there were you'd access and modify them like so: .when('/relatedStyle/:arbitraryParam',{ controller:'groupStylesLoad',...

What's the correct way to send parameters from AngularJS to an Options HTTP API?

angular-routing,http-options-method

Try this way return $http( { method: 'OPTIONS', url: apiUrl + '/Options?clientID=' + clientID } ).error( function ( a, b, c, d, e ) { console.log( 'err' ); } ); ...

Blueimp gallery not working in angularness when I enable html5mode

angularjs,blueimp,angular-routing

Try this directive: ;(function( angular, $ ) { 'use-strict'; angular.module('mosaic').directive('a', [ function blueImpFix() { function prevent(e) { e.preventDefault(); } function unprevent() { $(this).unbind('click', prevent); } return { restrict: 'E', link: function(scope, elem, attrs) { if('gallery' in attrs) { elem.bind('click', prevent).on('$destroy', unprevent); } return elem; } }; } ]); })( window.angular,...

How to get checkbox value in angularjs?

arrays,angularjs,asp.net-mvc-4,angularjs-filter,angular-routing

You can loop over the array to find out which is selected and push into the name array. <ul> <li ng-repeat="album in albums"> <input type="checkbox" ng-model="album.selected" value={{album.name}} /> </li> </ul> $scope.save = function(){ $scope.albumNameArray = []; angular.forEach($scope.albums, function(album){ if (!!album.selected) $scope.albumNameArray.push(album.name); }) } jsbin...

AngularJS ngRoute Child View not Loading the Javascript in the Parent View

javascript,angularjs,angular-routing

Having a very similar Issue using angular-ui-router. The CSS is applying fine but the JS is doing nothing. no matter where I load it; wither that be in the index page or my home page. does the ng-view / ui-view act as a namespace? that and DOM loading sequence is...

AngularJS: Changing Routes Based on Drop-Down Not Working

angularjs,angular-routing

You indeed can be more DRY than that. I would: Remove all go() functions from the views' controllers. Create a new controller (e.g. navCtrl) for the navigation "bar" Remove the ngClick directives from the <option> elements (since they don't seem to have any effect - at least in Chrome). Add...

How to load a page on a button click

angularjs,angular-routing,angular-ui-grid

use ng-routes in your application and give the url of the page you want to load as a templateUrl. then add $location.path('/path'); in the function you are calling.

What is the best practice method of using Angular JS routing with a Django backend?

django,angularjs,url,django-urls,angular-routing

If you want to serve the index.html for every url and then do the routing in angular you can do somethings like this in your <project_folder>.urls.py from <your_app> import views urlpatterns = patterns('', url(r'^.*$', views.index), ) ...

angular - Switch navbar when view is changed

angularjs,twitter-bootstrap,navbar,angular-routing

I think ng-include directive could solve the situation you are facing. In controller code. .controller('HeaderCtrl', function($scope, $location) { $scope.$on('$locationChangeSuccess', function(/* EDIT: remove params for jshint */) { var path = $location.path(); //EDIT: cope with other path $scope.templateUrl = (path==='/signin' || path==='/contact') ? 'template/header4signin.html' : 'template/header4normal.html' ; }); }) In Html....

Allowing both html5 and hashbang mode

angularjs,html5,angular-routing

That's how it's working in mine and I'm not doing anything special? If I type mysite.com/angularapp/#/accounts/29 using Chrome, it gets replaced with mysite.com/angularapp/accounts/29 My routing config contains: function($locationProvider) { $locationProvider.html5Mode(true).hashPrefix(""); } I'm on Angular 1.2.21, I'm not sure if that behavior would have changed on 1.3.x....

AngularJs configure route in callback inside app.config

javascript,angularjs,angular-ui-router,angular-routing

Drica! Using this implementation that @dfsq send, it will work, but this part app.controller('homeController', function($route) { window.route = $route; }); is not necessary if you use ui-route. Otherwise, this problem in the / route, you can use localStorage to save your json information and reload the page. In my tests,...

Angular JS Route: attach more than one controller

javascript,angularjs,angular-routing

What should happen is you should have ONLY ONE 'root' controller for a page, and any 'parts' of the page should be children of the root controller. $routeProvider .when('/store', { templateUrl: 'store.html', controller: 'StoreParentController' }) Then children can be declared in the HTML like so: <div ng-controller="StoreParentController"> <!-- you dont...

Common route resolver in angularjs?

javascript,angularjs,angular-routing,normalize

I set up a github repository yesterday which is a starting point for a web app and contains this feature here If you look in public/app/app-routes.js you will see I have added resolve functions as variables, then you can simply do this rather than writing a whole function each time:...

Creating Dynamic views based on ngRoute and a Restlike API

javascript,angularjs,angular-routing

I created working example here. NOTE: It uses UI-Router instead of ngRoute... which I guess is really the right way... but the concept is exactly the same. Firstly we would define the resoruce "player": .factory('player', ['$resource', function($resource){ return $resource('player:playerId.json', {}, { findAll: {method: 'GET', isArray: true}, get: {method: 'GET', isArray:...

Angular ui-router url parameter

angularjs,angular-ui-router,angular-routing

Option-1: You can use $location service. var t = $location.search().token Option-2 If you are using ui-router, you may access the querystring parameters from $stateParams service too var t = $stateParams.token Cheers!...

Nested parameterized routes with ui-router in AngularJS

angularjs,rest,angular-ui-router,angular-routing

I'll assume you have a REST api (based on your example containing /api/v1) which you want to expose/parallel as a UI. I'll assume you want to allow the user to drill down some hierarchical data model. Choices! There are many ways you could organize your states, for this drill-down list/details...

angularjs routing not working properly

angularjs,angular-routing

You have a typo in "teplateUrl". Changing it to "templateUrl" fixes your issue. .when("/user/:username", { "controller": "UserController", "templateUrl": "user.html" }) Updated fiddle here....

AngularJS router is not kicking in when I enter the base url in browser address bar

angularjs,angular-routing

This is a known issue with the angular-router: https://github.com/angular/angular.js/issues/1213. The discussion suggests a workaround which is not pretty. As far as I can tell, angular-ui-router has the same issue - see some details here: https://github.com/johnpapa/generator-hottowel/issues/22. At the moment, the best solution is to avoid nesting ng-view using an ng-include.

How to reduce code redundancy when defining routes in AngularJS

angularjs,rest,angular-resource,angular-routing

You can always take out the logic of Facility.get({id: $route.current.params.id}); in some service/factory but that would IMHO be just over-engineering. Apart from this, I don't see much redundancy, since most of that code is just declaration of things.

How to remove the hash # from the angularjs ng-route

javascript,angularjs,angular-routing

you can use the $locationProvider like this - $locationProvider.html5Mode({ enabled: true, requireBase: false }); Alternatively, you can use the base tag in your index.html (I suppose this is your landing page) <head> <base href="/"> </head> Removing base tag may cause some side effects in old IE browser like IE9...

MEAN stack: angular routing vs express routing [closed]

angularjs,express,routing,mean-stack,angular-routing

With the mean stack (mongo, express, angular) you will have routing at both ends. Express will serve your static index.html and css/js/images and your api, and angular will interact with the api to get data from mongo. Routing with express will primarily be done for the API, and routing in...

How to send search id to `$resource` prodiver?

angularjs,angular-routing

You need to configure $resource for 2 different params. Right now you are using the same param twice in the url so there is no way to parse object keys into 2 different ones It should be more like: // factory contractor : $resource( base + 'projects/:id/:contid') // controller server.contractor.get({id:$routeParams.id,...

AngularJS Routing Configuration not called

angularjs,angular-routing

In your MainController.js file, you defined a new module with same name as in app.js: angular.module("githubViewer", []); What you want to do is retrieve the already defined module. You can acheive that by removing the []: angular.module("githubViewer"); Look here at the "Creation versus Retrieval" section....

angular state get param child

angularjs,angular-ui-router,angular-routing

The point here is, that any call to 'demo.content' with different param process should re-call/re-init the controller of such state view. Other words, only controllers which are part of this state, could consume the process as a part of injected params. So, if there is really any part in main...

Angular updating and clearing factory variables

angularjs,angularjs-scope,angular-routing,angular-services

If you want it to wipe the value when they change routes (which logout should change routes also, I assume), you can watch the $routeChangeStart event and have it wipe the value whenever it occurs. You put that function in the module.run block: app.run(function ($rootScope, fact) { $rootScope.$on("$routeChangeStart",function(event, next, current){...

Pass Firebase Record Key into URL

javascript,angularjs,firebase,angularfire,angular-routing

ng-click="form.storeCheck(); appCtrl.pageLoad(form.urlKey)" In this code, you are saying run appCtrl.pageLoad() straight after form.storeCheck() which would be fine if this was an offline application with no data involved but in relality, appCtrl.pageLoad should only be called when storeCheck has been resolved which is not what you have implied here. There are...

Angular View automatically redirecting to default (otherwise) view

javascript,angularjs,redirect,angular-routing

I think your response.details has non-url encoded characters making the route provider think that you are navigating to a deeper page i.e. var response = {details:'bar/foo'}; would in effect be navigating to /view2/bar/foo triggering your otherwise.

How to make proper anchor tags when angular route is active

javascript,angularjs,angular-routing

I have to make this workaround in the same situation: Define function in scope: $scope.scrollTo = function (id) { var old = $location.hash(); $location.hash(id); $anchorScroll(); $location.hash(old); }; And call it this way: <a href="" data-ng-click="scrollTo('anchor')">Scroll to anchor</a> ...

AngularJS writing an app with no server

angularjs,google-chrome,angular-routing

As far as I know google chrome does not allow javascripts to be run from file system. But I did a quick google search and found this. Might be useful Link On the flipside you can use firefox. Firefox doesn't have such restrictions as far as I know...

Why is angularJs route and animate skipping my second redirect?

javascript,html,angularjs,animation,angular-routing

When on a second level page the animation between that page and another second level page gets cut off the first time. Every other time it works fine. It sounds like this is a networking/caching issue. Someone in the comments section of that article had a similar issue and...

How to define optional parameter using UI-Router without trailing slash as well?

javascript,angularjs,angular-ui-router,angular-routing

There is a working example We can use params : {} object to define the userid exactly as we need (i.e. ready to be omitted). Check more details about params here: Angular ui router passing data between states without URL $stateProvider .state('viewallcards', { url: '/my-app/home/:userid', params: { userid: {squash: true,...

Module 'ui.bootstrap' is not available - Angularjs

javascript,angularjs,angular-ui,angular-routing

All of your script tags are using absolute paths (they start with a /) except for the angular-bootstrap tags; they use relative paths. That means they are relative to wherever you are in the browser. Your javascript files are all located at www.website.com/Scripts/... because all of your script tags except...

Angularjs - how to set template content from server json answer?

javascript,angularjs,angular-routing

I have not found the right way to solve the problem, so I decided it so: in a $rootScope I create pageTitle variable, that contains my page title i bind pageTitle to the title of my html from server now I receive only html-content with ng-init="$root.pageTitle='Page title'" ...

angular Routing without Hash

angular-routing

By Setting Up the Routings On Server Side, this problem is solved

MVC5 and Angular.js routing - URLs not matching

asp.net-mvc,angularjs,angular-routing

Angular is by design a Single Page Application (SPA) framework. It is designed to process requests within a single server page request, and handle route changes without making subsequent calls to the server. Hence, for every page load, the page is at the "root" of the application. or /, no...

How do I throw a real 404 or 301 with an Angular pushstate URL

angularjs,seo,http-status-code-404,pushstate,angular-routing

The real question is does http://example.com/pet/123456 return anything at all? If your starting point is http://example.com/ and there's a link to http://example.com/pet/123456 then Angular will call the petController which in turn makes an AJAX call to http://example.com/api/pet/123456. A crawler wouldn't do that but instead would try to call http://example.com/pet/123456 directly....

How to work with ui.router's $stateChangeStart in angularjs?

angularjs,angular-ui-router,angular-routing

If you home page is a plain static page - then nothing is required - the template for the home page is already cached in the $templateCache. Else if your home page has some data that is fetched from some service, I would suggest you to cache the data in...

Angular Routing - Wait for previous resolve

angularjs,angular-routing,resolve,route-provider

If you inject the first resolve result (login in your case) to the the 2nd resolve, then that resolve will be delayed until that value is loaded. If it's not loaded or there is an error, it will not trigger: $stateProvider.state('/admin/:one/:two/:three?', { templateUrl: '/app/partials/admin.html', controller: 'AdminCtrl', resolve: { login: function(LoginService)...

ExpressJS paired with AngularJS Routing without hashtag on links

angularjs,node.js,express,angular-routing

I may be wrong about this, but it seems that you may be confusing client side routes with server side routes. Routes defined via ngRouter are not supposed to hit server at all. I modified your code to make it work. It should be enough to let you go on...

How to do nested routing using one template & controller in angularjs?

javascript,angularjs,angular-routing

You need to use * in $routeProvider that will match all the characters in the url, when : is used it will match all characters till /. Change your code $routeProvider( when('/albums/:albumName), { templateUrl : 'albumsList.html', controller : 'albumsCtrl' }) To $routeProvider( when('/albums/:albumName*), { templateUrl : 'albumsList.html', controller : 'albumsCtrl'...

Angular ui-router seems to re-write url automatically on load

angularjs,angular-ui-router,angular-routing

I finally solved this ( I think). Looks like it's a dependency issue. Once I removed HistoryJS (1.8.0), everything worked as expected. <script src="/bower_components/history/scripts/bundled/html4+html5/native.history.js" type="text/javascript"></script> ...