We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Angular template with controller as vm without $scope

Thread ID:





121766 Jan 22,2016 02:24 PM UTC Jan 26,2016 04:24 AM UTC JavaScript 3
Tags: ejGrid
Asked On January 22, 2016 02:24 PM UTC


I am trying to add ng-template column to the grid, with click action. It works fine with $parent referring to controller's scope. However I cannot figure out, is it possible to use Controller-As angular pattern?

Here is my simple example:

 <script type="text/ng-template" id="actionTemplate1">
        <span ng-click='$parent.alertPerScope(data.Color)'> {{"click me: "+ data.Color}}  //WORKS

      <script type="text/ng-template" id="actionTemplate2">
        <span ng-click='vm.alertPerVm(data.Color)'> {{"vm.click me: "+ data.Color}} //DOESNT WORK

Venkatesh Ayothi Raman [Syncfusion]
Replied On January 25, 2016 12:34 PM UTC

Hi Ricardas,
Thanks for Contacting Syncfusion Support.
We have analyzed and achieved your query.
You can able to use Controller-As angular pattern In grid but the problem is, if you have directly accessed a Child Scope controller named “vm” in your code snippet because scope is only created for grid. Templates are used inside grid, it is like a child scope and grid is a parent scope.
We suggest you to use parent scope to access a click option through Controller as “vm” and use code like below:

<script type="text/ng-template" id="actionTemplate2">
<span ng-click='$parent.vm.alertPerVm(data.Color)'>{{"vm.click me: "+ data.Color}}

Try the above solution, still If you are facing the same issue, kindly share the issue reproducing sample.
Venkatesh Ayothiraman.

Replied On January 25, 2016 03:31 PM UTC

Great, it's working! Many thanks!

Gowthami V [Syncfusion]
Replied On January 26, 2016 04:24 AM UTC

Hi Ricardas,
We are happy to hear that your has been resolved.
Get back to us if you need further assistance.
Gowthami V.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon