简体   繁体   中英

Passing objects from a view to controller

I am passing few parameters from a view to a directive. Currently, I am passing that as

<text-logo class="cmp_logo default-logo-style">{ 'logo' => "{{row.logo}}", 'subtext' => "{{row.name}}", 'height' => "75", 'width' => "75", 'cx' => "37", 'cy' => "37", 'r' => "35", 'font_size'=> "25", 'y' => "47", 'x' => "21" }</text-logo>

I want to pass the parameters as an object, like

'style': {
  'height': 75,
  'width': 75,
  'cx': 37
}

How can I implement that in my view? How can I pass it to my controller?

I think that you only need ng-model="obj" and you can access it in your controller by $scope. ie $scope.obj

<text-logo ng-model="obj" class="cmp_logo default-logo-style">{ 'logo' => "{{row.logo}}", 'subtext' => "{{row.name}}", 'height' => "75", 'width' => "75", 'cx' => "37", 'cy' => "37", 'r' => "35", 'font_size'=> "25", 'y' => "47", 'x' => "21" }</text-logo>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM