main.controller.js 574 B

1234567891011121314151617181920212223242526272829303132
  1. (function () {
  2. 'use strict';
  3. app.controller('Main', function($scope) {
  4. console.log("OK");
  5. console.log($scope);
  6. $scope.style = {
  7. width: 100,
  8. height: 100,
  9. background: "red",
  10. }
  11. $scope.x = 2;
  12. $scope.y = 3;
  13. $scope.color = 'red';
  14. $scope.data = ['apples', 'oranges', 'berries'];
  15. console.log($scope);
  16. $scope.sum = function() {
  17. $scope.result = $scope.x + $scope.y;
  18. console.log(this.x);
  19. }
  20. $scope.addItem = function() {
  21. $scope.data.push($scope.item);
  22. $scope.item = "";
  23. }
  24. $scope.deleteItem = function(index) {
  25. $scope.data.splice(index, 1);
  26. }
  27. });
  28. })();