2014-04-01 64 views
0

我有以下代碼Angularjs使用CSS3動畫

<a href="#local-container" >X</a> 

於是就點擊此鏈接的URL更改

http://localhost:8088/#/local-container 
在angularjs

,這個問題是我必須捕獲活動元素點擊從我的CSS動畫一個DOM元素在下面的代碼,

#local-container:target{ 
left:0px; 
width:10px; 
} 

而且顯然它不會w ork,因爲hashtag與上面css中的div id不一樣。

所以是有另一種方式acheive動畫? 或者我必須改變在angularjs URL模式?

回答

0

我認爲你正在尋找的東西像$anchorScroll()

Here is the documentation

+0

的網址改爲'的http://本地主機:8088/##本地container',我想通過'http://本地主機:8088 /#本地container'有一個額外的哈希值。 –

+0

如果你真的想在href保持 '#',你可能會想這樣做:'$ scope.scrollTo =功能(ID){VAR 舊= $的location.hash(); $ location.hash(id); $ anchorScroll(); //重置爲舊保留任何額外的路由邏輯從 $的location.hash踢(舊); };' – adam

+0

對不起@adam但我覺得你的答案是斷章取義。用CSS我是動畫的div。 –