Вопрос

Below is the code. The click event does not work. in ng-click i have included "insertTom()".

GOOGLE CDN : https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js

  var myAppModule = angular.module('myApp', []);

  var students = [{name:'Mary Contrary', id:'1'},

                  {name:'Jack Sprat', id:'2'},

                   {name:'Jill Hill', id:'3'}];

  function StudentListController($scope) {

      $scope.students = students;

      $scope.insertTom = function () {

      $scope.students.splice(1, 0, {name:'Tom Thumb', id:'4'});

  };

}

Это было полезно?

Решение

<div ng-controller="StudentListController">
  <!-- content -->
  <button type="button" ng-click="insertTom()">Insert</button>
</div>

No problem, you will enjoy angular :)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top