javascript - angularjs ionic app add two numbers one from database and other from input -


i'm trying add 2 numbers in application. 1 number database , other want insert in application. simple i'm new angularjs. code:

html :

<div class="item-input-inset">  <label class="item-input-wrapper">     <input type="number" placeholder="insert points" ng-model="inp"/>    </label>    </div>    <span> {{sum()}} </span>app.js 

app.js

.controller('appctrl', function($scope, pointservice) { $scope.points = 0; $scope.inp = 0;  $scope.sum = function(){  return $scope.points + $scope.inp } 

all app display number 9 $scope.points in database 9 doesn't add input number when try input number. please help?

that whole app.js delete points functions not finished yet

 // ionic starter app // angular.module global place creating, registering , retrieving angular modules // 'starter' name of angular module example (also set in          <body> attribute in index.html) // 2nd parameter array of 'requires' angular.module('starter', ['ionic', 'backand'])  .config(function (backandprovider) { backandprovider.setappname('dozr'); backandprovider.setanonymoustoken('00890966-560c-49a9-96af-8203d8645186'); })   .controller('appctrl', function($scope, pointservice) { $scope.points = 0; $scope.inp = 0;     function getmypoints() {  pointservice.getpoints()  .then(function (result) {   $scope.points = result.data.name;  });  }   $scope.sum = function(){   return $scope.points + $scope.inp }     $scope.addpoint = function() {    pointservice.addpoint($scope.sum)  .then(function(result) {   $scope.input = 0;   // reload our points, not super cool   getmypoints(); }); }  //$scope.deletepoint = function(id) { //pointservice.deletepoint(id) //.then(function (result) {   // reload our points, not super cool   //getallpoints(); // }); //}  // getmypoints(); //})  .service('pointservice', function ($http, backand) { var baseurl = '/1/objects/'; var objectname = 'points/';    function geturl() { return backand.getapiurl() + baseurl + objectname; }  function geturlforid(id) { return geturl() + id; }  getpoints = function (id) { return $http.get(geturlforid(1)); };  addpoint = function(point) { return $http.put(geturlforid(1), point); }  deletepoint = function (id) { return $http.delete(geturlforid(id)); };  return { getpoints: getpoints, addpoint: addpoint, deletepoint: deletepoint } }); 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -