내가 지금까지 발견 한 작업 : 주 컨트롤러에 $ 위치 종속성을 추가하면 $ location.hash가 ''를 반환하고 $ location.path가 '/ path # sectionId'를 반환합니다. 이를 바탕으로
는
, 우리는 컨트롤러의 상단에 다음과 같이 뭔가를 추가 할 수 있습니다
// when has in url is encoded to %23, location.hash does not recognize it, and it gets cleared from the path in $RouteProvider
var holdHash = $location.path();
holdHash = holdHash.split('#');
if (holdHash.length > 1) { // if it has an item after the hash in the array
$location.hash(holdHash.pop()); //take that item and use it as a hash
}
하지만 당신은 $의 location.search
의 값을 잃거나 당신이 할 수 있습니다 :
를
$location.url(decodeURIComponent($location.url()))
검색을 유지하지만 '?'대신 사용할 수 있습니다. '% 3F'와 비교하여 $ location.search가 아닌 $ location.ash에 반환합니다.
그들은 해키 솔루션 어떻게 든 조금, 그리고 완전히 ****
***** 편집이 솔루션 (은 $ location.search 문제 참조)
으로 작동하지 않습니다 내 문제에 대한 최종 해결책은 ID를 저장 한 서비스를 업데이트하고 메인 컨트롤러에서 해시 탐지를 먼저 트리거합니다.
/**
* tries to get hash from $location
* if unavailable tries to look for encoded hash
* if unavailable returns null
* @return {string or null} [a string with the id of the section or null]
*/
function getHashID() {
var fromLoc = $location.hash(),
fromEncodedUrl,
inPath;
if (fromLoc.length) {
return fromLoc;
}
// iphone Chrome encodes the pound sign on redirect
fromEncodedUrl = $location.url();
fromEncodedUrl = fromEncodedUrl.split('%23');
if (fromEncodedUrl.length > 1) {
return fromEncodedUrl.pop();
}
inPath = $location.path();
inPath = inPath.split('#');
if (inPath.length > 1) {
return inPath.pop();
}
return null;
}
내가 나중에 서비스 객체, 또는 새로운 값을 얻기에 저장된 값에 애니메이션을 트리거하고, 애니메이션 후 : 또한이 염두에 저장할 수있는 모든 변화를 유지하기 위해 탐지를 가지고 업데이트 서비스에서 가치를 지 웁니다.