File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
src/javascripts/ng-admin/Crud/misc Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change 22 * Help text for a form field.
33 *
44 * @example <ma-help-text field="field"></ma-help-text>
5+ *
6+ * @param field.helpText() If a string, it will be displayed as text to the user.
7+ * If an `angular.element`, it will be compiled and displayed.
8+ * You can use "entry.values[x]" to check the current value
9+ * of property "x" (e.g. if you want to give different hints)
510 */
6- export default function maHelpText ( ) {
11+ export default function maHelpText ( $compile ) {
712 return {
8- scope : {
9- 'field' : '&'
10- } ,
13+ scope : true ,
1114 restrict : 'E' ,
1215 link : function ( scope , element ) {
13- var field = scope . field ( ) ;
14- scope . helpText = field . helpText ( ) ;
16+ var field = scope . field ;
17+
18+ var helpText = field && field . helpText ( ) ;
19+ if ( helpText && typeof helpText === "object" && helpText . contents ) {
20+ // looks like an angular.element:
21+ element . append ( helpText . clone ( ) ) ;
22+ $compile ( element . contents ( ) ) ( scope ) ;
23+ } else {
24+ // treat as plain text:
25+ scope . helpText = helpText ;
26+ }
1527 } ,
1628 template : '<small ng-if="helpText" class="help-block">{{ helpText }}</small>'
1729 } ;
1830}
1931
20- maHelpText . $inject = [ ] ;
32+ maHelpText . $inject = [ '$compile' ] ;
You can’t perform that action at this time.
0 commit comments