What's the correct way to change the cursor?

5,936 views
Skip to first unread message

Brett Wiesner

unread,
Mar 7, 2013, 10:37:21 AM3/7/13
to ang...@googlegroups.com
Hi,

What's the correct way to change the cursor in an angular application? I ask the user to click on a point on the map and I want to change the cursor to a crosshair (for example) while its waiting for the user to do that.

Thanks,
Brett

Peter Bacon Darwin

unread,
Mar 7, 2013, 10:46:06 AM3/7/13
to ang...@googlegroups.com
Can you do it by changing the CSS class of the body?


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Andy Joslin

unread,
Mar 7, 2013, 10:46:40 AM3/7/13
to ang...@googlegroups.com
html:
<map ng-class="{crosshair: waitingForInput}"></map>

js:
$scope.waitingForInput = true

css:
.crosshair {
  cursor: crosshair;
}

Brett Wiesner

unread,
Mar 7, 2013, 11:35:49 AM3/7/13
to ang...@googlegroups.com
Thanks Andy. Here's a simple plunker that's not quite working...





Thanks,
Brett
--

Brett Wiesner
VT MÄK, Director of New Product Innovation
150 Cambridge Park Drive, 3rd Floor, Cambridge, MA, 02140
T: +1.857.209.3471  Email: br...@mak.com 
labs.mak.com

Where Live, Virtual, and Constructive Simulation Meets the Web



}

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/4azcQ8CwMvY/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

Brian Matthews

unread,
Mar 7, 2013, 3:03:43 PM3/7/13
to ang...@googlegroups.com
Brett,



The stylesheet is not loading (use href attribute instead of src attribute). Also, the classname should be a string in your example.

See this fork of your example:

Clint Checketts

unread,
Mar 7, 2013, 3:08:48 PM3/7/13
to ang...@googlegroups.com
Just for kicks I made it so the 'waitForInput' is toggled when you click it, so you can see the cursor change on and off.



--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

Brett Wiesner

unread,
Mar 7, 2013, 4:14:57 PM3/7/13
to ang...@googlegroups.com
Thanks guys! 

Thanks,
Brett
--

Brett Wiesner
VT MÄK, Director of New Product Innovation
150 Cambridge Park Drive, 3rd Floor, Cambridge, MA, 02140
T: +1.857.209.3471  Email: br...@mak.com 
labs.mak.com

Where Live, Virtual, and Constructive Simulation Meets the Web



Brett Wiesner

unread,
Mar 7, 2013, 5:22:56 PM3/7/13
to ang...@googlegroups.com
I guess I should have mentioned I'm using an openlayers map. This plunker integrates the ng-class code with a map controller and illustrates the problem.


OpenLayers might be messing with the cursor (click and drag and the cursor changes) so is there anyway to override what its doing?


Thanks,
Brett
--

Brett Wiesner
VT MÄK, Director of New Product Innovation
150 Cambridge Park Drive, 3rd Floor, Cambridge, MA, 02140
T: +1.857.209.3471  Email: br...@mak.com 
labs.mak.com

Where Live, Virtual, and Constructive Simulation Meets the Web



Brian Matthews

unread,
Mar 7, 2013, 5:30:57 PM3/7/13
to ang...@googlegroups.com
You'll need to get more specific with your "crosshair" css selector or add "!important" to the rule.   Also,  the classname should be a string in ng-class -  ng-class="{'my-class-name-in-quotes': myVar}"

Brett Wiesner

unread,
Mar 8, 2013, 8:58:27 AM3/8/13
to ang...@googlegroups.com
Thanks guys! This worked "for real" this time!

Thanks,
Brett
--

Brett Wiesner
VT MÄK, Director of New Product Innovation
150 Cambridge Park Drive, 3rd Floor, Cambridge, MA, 02140
T: +1.857.209.3471  Email: br...@mak.com 
labs.mak.com

Where Live, Virtual, and Constructive Simulation Meets the Web



Reply all
Reply to author
Forward
0 new messages