我对Angular很新。我想在ng-grid的自定义单元格模板中应用ng-class中的自定义类。我熟悉“ng-class”的整体用法。默认模板如下:
tell application "Safari"
quit
end tell
set defaultAnswer to ""
set cancelButton to "Cancel"
set buttonResearch to "ReSearch"
display dialog "Query: " default answer defaultAnswer buttons {cancelButton, buttonResearch} default button buttonResearch cancel button cancelButton with icon 1
copy the result as list to {button_pressed, text_returned}
tell application "Dragon Dictate"
set listening to false
end tell
if (button_pressed is buttonResearch) and (text_returned is not "") then
set theUrl to "http://www.wolframalpha.com/input/?i=" & encode_text(text_returned, true, false)
tell application "Safari"
tell window 1 to set current tab to (make new tab with properties {URL:theUrl})
tell me to say "let me look that up for you now"
tell document 1
repeat -- wait until loaded
delay 2
if (do JavaScript "document.readyState") = "complete" then exit repeat
end repeat
do JavaScript "document.getElementById('pod_0200').getElementsByClassName('action subpod-copyablept ')[0].click()" -- show the popup window
set theAnswer to do JavaScript "document.body.lastChild.getElementsByTagName('pre')[0].innerHTML;" -- get the answer in this popup window
end tell
end tell
activate
if theAnswer contains "msng" then
display dialog "There was an error, you may have misspelled a word or phrased it incorrectly"
else
display dialog theAnswer
end if
end if
tell application "Safari"
quit
end tell
-- encoding high-ASCII characters:
on encode_char(this_char)
set the ASCII_num to (the ASCII number this_char)
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
set x to item ((ASCII_num div 16) + 1) of the hex_list
set y to item ((ASCII_num mod 16) + 1) of the hex_list
return ("%" & x & y) as string
end encode_char
-- TEXT ENCODING: encode spaces and high-level ASCII characters (those above 127)
-- encode_URL_A = encode most of the special characters reserved for use by URLs.
on encode_text(this_text, encode_URL_A, encode_URL_B)
set the standard_characters to "abcdefghijklmnopqrstuvwxyz0123456789"
set the URL_A_chars to "$+!'/?;&@=#%><{}[]\"~`^\\|*"
set the URL_B_chars to ".-_:"
set the acceptable_characters to the standard_characters
if encode_URL_A is false then set the acceptable_characters to the acceptable_characters & the URL_A_chars
if encode_URL_B is false then set the acceptable_characters to the acceptable_characters & the URL_B_chars
set the encoded_text to ""
repeat with this_char in this_text
if this_char is in the acceptable_characters then
set the encoded_text to (the encoded_text & this_char)
else
set the encoded_text to (the encoded_text & encode_char(this_char)) as string
end if
end repeat
return the encoded_text
end encode_text
现在,我想添加一个基于行数据的新类。说:
<div class="ngCellText" ng-class="col.colIndex()"><span ng-cell-text> {{row.getProperty(col.field)}}</span></div>
问题: ng-grid中已经存在ng-class中的 col.colIndex()。现在如何用它添加我的课程?
我知道这似乎很容易,但它无法正常工作。
我试过以下事情:
ng-class="myClass:row.entity.Flag == 'something'"
。没工作。 我只想要一个有效的'ng-grid'模板(如上所述)。
答案 0 :(得分:0)
尝试使用
row.entity.subGridOptions.Flag
答案 1 :(得分:0)
经过进一步研究后,我得到了答案。
我想添加一个类,通过该类可以触发ng-grid行上的数据。我将它应用于rowTemplate
,但rowTemplate本身没有任何文本数据。
我必须在cellTemplate
中应用它,它实际上将包含文本。
@Jesse,感谢你的回答。
答案 2 :(得分:0)
ng-class =“{\''red \':row.entity.Expiration == \'No \'}”