1

I need to call a js function when an ng-repeat template is created:

<div ng-repeat="item in items">
  <input id="ip{{item.id}}">
  <script>$(function () { $('#ip{{item.id}}').kendoDatePicker(); });</script>
</div>

The id is replaced as expected, but angular doesn't seem to work inside script tags.

2
  • why do you need to use it inside script tags Commented Jul 22, 2014 at 10:15
  • 1
    I'd recommend using the kendo angular tools. Commented Jul 22, 2014 at 10:15

1 Answer 1

2

That is correct, Angular will not evaluate expressions in script tags. You will need to use a directive that will initialize the Kendo plugin for each element.

The good news is Kendo already has a module for integrating with Angular, so you might as well just use that. Here is a plunk I put together showing it in a repeater.

<div ng-repeat="item in items">
  <label for="{{item.id}}">{{item.id}}</label>
  <div>
    <input kendo-date-picker ng-model="item.value" />
  </div>
</div>

Controller:

angular.module("demo", ['kendo.directives'])
  .controller('DemoCtrl', ['$scope',
    function($scope) {
      $scope.items = [{
        id: 'item1',
        value: null
      }, {
        id: 'item2',
        value: null
      }, {
        id: 'item3',
        value: null
      }, {
        id: 'item4',
        value: null
      }];
    }
  ]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.