2016-07-11 1 views
-1

안녕 (그것이 angurla - 툴팁 플러그인에 대한 attribut의) 내 html 태그 중 하나의 값을 tooltip attribut을 따르있어 :attribut 값의 문자열을 확인

<div tooltip="{ data: { onChange: ctrl.onChangeInTooltip }, template: '<wsc-number-input-helper-tooltip on-change=&quot;ctrl.data.onChange&quot;></wsc-number-input-helper-tooltip>', class: 'cNumberInputHelperTooltip', pointerPosition: 'End'}"></div> 

을 내가 할 수있는 방법 문자열 및 tooltip 특성 내의 attribut 값에서 내 자바 스크립트 변수에 할당 할? 나는 이것을 이렇게 시도했다 :

let myAttributValue = "{ data: { onChange: ctrl.onChangeInTooltip }, template: '<wsc-number-input-helper-tooltip on-change=&quot;ctrl.data.onChange&quot;></wsc-number-input-helper-tooltip>', class: 'cNumberInputHelperTooltip', pointerPosition: 'End'}"; 
let myAttributValue = "{ data: { onChange: ctrl.onChangeInTooltip }, template: &quot;<wsc-number-input-helper-tooltip on-change=&quot;ctrl.data.onChange&quot;></wsc-number-input-helper-tooltip>&quot;, class: &quot;cNumberInputHelperTooltip&quot;, pointerPosition: &quot;End&quot;}"; 

둘 다 작동하지 않는다.

아이디어가 있으십니까?

EDIT (SOLUTION) :How can I build a json string in javascript/jquery? - 그것은 JSON.stringify()

감사

와 함께 작동
+0

그래서 데이터 묶음을 변수에 저장하고'tooltip' 속성에 넣으려고합니까? –

+0

시도해보십시오 myAttributValue = JSON.parse (myAttributValue) –

+0

@Rakesh Kumar가 직접 시도해보십시오. 작동하지 않는다는 것을 알 수 있습니다. –

답변

1

바인딩 예를 들어, 이중 괄호 구문을 사용 각도 : 자바 스크립트에

<div tooltip="{{Thisisthetooltip}}" ... > 

는 것 have :

$scope.Thisisthetooltip = "This is the actual tooltip text" ; 

편집 :

툴팁의 내용은 JSON과 같은 문자열 내에있는 경우, 당신이 할 수있는이 여전히 귀하의 질문에 대답하지 않는 경우

var l_tempo = JSON.parse(<your string>) ; 
$scope.Thisisthetooltip = l_tempo.<the path to the element within the JSON> ; 

, 당신이 아래로 투표를 남길 수 있습니다.

+0

이것은 내 문제를 해결하지 못합니다. 자바 스크립트 변수에 위의 문자열을 할당하는 방법을 모르겠습니다. 이게 정말 도움이되지 않습니다 ... – MrBuggy

+0

"할당"이라는 것이 무슨 뜻인지 분명하지 않습니다. 과제는 어디에서 일어나고 있습니까? – FDavidov

+0

내 질문에 다시 살펴보면 첫 번째 코드에서 속성 툴팁이있는 div를 볼 수 있습니다. 이 특성에는 가치가 있습니다. 이제 두 번째 코드를 살펴보면 특성 값을 복사하고 문자열을 만들어 변수에 넣고 싶습니다. 변수 myAttributeValue에서 시도했지만 올바르지 않습니다. 올바른 것은 아닙니다. string ... – MrBuggy

관련 문제