Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am new using Angularjs and KendoUI, I am trying to open multiple windows using kendoUI and add an angularjs html external file in it, the problem is when I attempt to open the window, the html page that is inside of the window opens correctly but the angular code that is in it it doesn't work.

This is my main page index.html:

<!DOCTYPE html>
<html>
<head>
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.226/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.226/styles/kendo.material.min.css" />

    <script src="//kendo.cdn.telerik.com/2016.1.226/js/jquery.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2016.1.226/js/angular.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2016.1.226/js/kendo.all.min.js"></script>
</head>
<body>

<div id="example" ng-app="KendoDemos">
    <div ng-controller="MyCtrl">       
        <div class="demo-section k-content">
            <button class="k-button" ng-click="open()">Content</button>
        </div>
        <p>{{ data.fName }}</p>

    </div>
    <style>
        .example {
            min-height: 400px;
        }
    </style>
</div>

<script>
  angular.module("KendoDemos", [ "kendo.directives" ])
      .controller("MyCtrl", function($scope){
           var noteNumber = 0;
            $scope.data= {
                  fName : 'hello'
              }

          $scope.open=function(){

            var noteWindowDivId = "noteWindow" + noteNumber;

 $("<div id=noteWindowDivId />").appendTo(document.body).kendoWindow ({
        draggable: true,
        resizable: true, 
        width: "500px",
        height: "375px", 
        title: "Multiventanas",
        scrollable: true,
        modal: false, 
        content : "databinding.html" ,
        actions: ["Minimize", "Maximize", "Close"]
    });    
    $("#noteWindowDivId").data("kendoWindow");
    noteNumber++;

 }
      })

</script>

</body>
</html>

This is my Angular external file "databinding.html" :

    <div ng-app="invoice1" ng-controller="InvoiceController as invoice">
         <script src="js/angular.js" type="text/javascript"></script>
        <script src="js/invoice1.js" type="text/javascript"></script>
  <b>Invoice:</b>
  <div>
    Quantity: <input type="number" min="0" ng-model="invoice.qty" required >
  </div>
  <div>
    Costs: <input type="number" min="0" ng-model="invoice.cost" required >
    <select ng-model="invoice.inCurr">
      <option ng-repeat="c in invoice.currencies">{{c}}</option>
    </select>
  </div>
  <div>
    <b>Total:</b>
    <span ng-repeat="c in invoice.currencies">
      {{invoice.total(c) | currency:c}}
    </span>
    <button class="btn" ng-click="invoice.pay()">Pay</button>
  </div>
</div>

The thing is when the databinding.html shows in the windows, all databinding made in angular is lost and anything on angular works, so i would like that you tell me if i am doing something wrong or how can i put that html inside a kendo windows and that angular code works correctly.

Thanks.

share|improve this question

Finally I did this exercise taking this note from KendoUi web page : http://docs.telerik.com/kendo-ui/AngularJS/how-to/window-service

When you create the kendo Window, in the definition you have to reference the controller that is going to bind the data to the view or template that you want to show in the window.

This is my index.html

<!DOCTYPE html>
<html>
<head>
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.226/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.226/styles/kendo.material.min.css" />

    <script src="//kendo.cdn.telerik.com/2016.1.226/js/jquery.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2016.1.226/js/angular.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2016.1.226/js/kendo.all.min.js"></script>
    <script src="js/kendoUI/angular-kendo-window.js" type="text/javascript"></script>
    <script src="js/angular.js" type="text/javascript"></script>
</head>
<body>

<div id="example" ng-app="KendoDemos">
    <div ng-controller="MyCtrl">

        <div class="demo-section k-content">
            <button class="k-button" ng-click="open()">Contenido</button>
        </div>
        <p>{{ fName }}</p>

    </div>
    <style>
        .example {
            min-height: 400px;
        }
    </style>


</div>

<script>
  var MyApp = angular.module("KendoDemos", [ "kendo.window", "kendo.directives" ]);
  MyApp.controller("MyCtrl", MyCtrl);
  MyApp.controller("InvoiceController", InvoiceController);

  function MyCtrl($scope, $kWindow) {
           var noteNumber = 0;
          //$scope.hello = "Hello from Controller!";
          $scope.fName = 'Esta es una prueba data from parent window to child';
          var noteWindowDivId = "noteWindow" + noteNumber;

          $scope.open=function(){

        var windowInstance = $kWindow.open({
                       options:{
                         draggable: true,
                         resizable: true, 
                         width: "500px",
                         height: "375px", 
                         title: 'Multiventanas',
                         scrollable: true,
                         actions: ["Minimize", "Maximize", "Close"],
                         visible: false
                       },
                        templateUrl: 'template/window/databinding2.html',
                        controller: 'InvoiceController',
                        resolve: {
                            message: function () {
                                return $scope.fName;
                            }
                        }
                    });

 };
      }

    function InvoiceController($scope,  message) {
    $scope.message333 = message;
    $scope.qty = 1;
    $scope.cost = 2;
    $scope.inCurr = 'EUR';
    $scope.currencies = ['USD', 'EUR', 'CNY'];
    $scope.usdToForeignRates = {
      USD: 1,
      EUR: 0.74,
      CNY: 6.09
    };

    $scope.total = function total(outCurr) {
      return $scope.convertCurrency($scope.qty * $scope.cost, $scope.inCurr, outCurr);
    };
    $scope.convertCurrency = function convertCurrency(amount, inCurr, outCurr) {
      return amount * $scope.usdToForeignRates[outCurr] / $scope.usdToForeignRates[inCurr];
    };
    $scope.pay = function pay() {
      window.alert("Thanks!");
    };


}


MyCtrl.$inject = ['$scope', '$kWindow'];
</script>



</body>
</html>

databinding2.html

<div>
  <b>Invoice:</b>
  <div>
    Quantity: <input type="number" min="0" ng-model="qty" required >
  </div>
  <div>
    Costs: <input type="number" min="0" ng-model="cost" required >
    <select ng-model="inCurr">
      <option ng-repeat="c in currencies">{{c}}</option>
    </select>
  </div>
  <div>
    <b>Total:</b>
    <span ng-repeat="c in currencies">
      {{total(c) | currency:c}}
    </span>
    <button class="btn" ng-click="pay()">Pay</button>
  </div>
  <h3>{{message333}}</h3>
</div>

You don't have to write a entire html format as you external html file (Child) because it depends on its parent form. I hope this example can help to somebody!!! have a nice day.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.