Answer the question
In order to leave comments, you need to log in
How to transfer values from one $Scope to another $Scope?
In $scope.addItem1 = function Start(dateBegin) a variable var dateBegin = new Date() is created, then it is converted to time, this all happens when you press the Start key, after that I press the Stop key and the data should be entered on the screen in the table , one of which is ,dateEnd and dateBegin, but it says that dateBegin is not assigned to $scope.addItem = function Stop(text, project,dateBegin,dateEnd,date)
purchaseApp.controller("purchaseController", function ($scope) {
$scope.list = model;
$scope.addItem1 = function Start(dateBegin) {
var dateBegin = new Date();
var dateBegin = dateBegin.toLocaleTimeString();
console.log(dateBegin);
}
$scope.addItem = function Stop(text, project,dateBegin,dateEnd,date) {
dateEnd = new Date();
dateEnd = dateEnd.toLocaleTimeString();
var date= dateEnd- dateBegin;
console.log(dateBegin);
if(text != "")
{
$scope.list.items.push({ purchase: text, project: project,dateBegin:dateBegin,dateEnd: dateEnd,date:date});
}
}
});
Answer the question
In order to leave comments, you need to log in
Here is an extended answer.
stackoverflow.com/questions/500431/what-is-the-sco...
Your question has nothing to do with your code.
1) Your problem is not with scopes, but with scopes (in English, this is the same thing). And here you need to read not the link above, but https://github.com/casufi/You-Dont-Know-JS
2) Everything that you store in the scope adds watch to your application and eventually it will die, don't do it.
https://www.sitepoint.com/writing-angularjs-apps-u...
You need to first read the links, and then throw out your piece of code and write it all over again.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question