javascript - AngularJS Custom Directive shows {{obj}} but not {{obj.prop}}? -


i'm trying build simple angular directive:

app.directive("mydirective", function () {     return {         template: "{{result}} {{result.starttime}}",         scope: {             result: '@result'         }     }; }); 

and use way in view:

<div my-directive result="{{result}}"></div> 

the problem {{result}} displayed correctly (as json) abject, while {{result.starttime}} not displayed, despite fact displayed {{result}} contains starttime property.

2 problems:

1 need pass model in, not interpolated string.

<div my-directive result="result"></div> 

2 need assign value directive, use '=' instead of '@' gives 1-way binding directive dom only.

app.directive("mydirective", function () {     return {         template: "{{result}}, {{result.starttime}}",         scope: {             result: '='         }     }; }); 

working demo


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -