Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:angularjs:js文件_Angularjs_Node.js_Cordova - Fatal编程技术网

错误:angularjs:js文件

错误:angularjs:js文件,angularjs,node.js,cordova,Angularjs,Node.js,Cordova,这是我的js文件我不知道为什么它不工作,我想从js文件执行cordova cmd:当我点击按钮时,项目将被创建: (function(angular) { 'use strict'; var myApp = angular.module("myApp", []); myApp.factory("items", function() { var items = {}; items.data = []; return items; }); myApp.contr

这是我的js文件我不知道为什么它不工作,我想从js文件执行cordova cmd:当我点击按钮时,项目将被创建:

(function(angular) {
 'use strict';
  var myApp = angular.module("myApp", []);
  myApp.factory("items", function() {
  var items = {};
   items.data = [];
   return items;
    });
  myApp.controller("createController", function createController($scope,    items) {
$scope.items = items;

$scope.deleteItem = function(index) {
  items.data.splice(index, 1);
}
$scope.addItem = function(index) {
  items.data.push({
    id: $scope.items.data.length + 1,
    title: $scope.newName
  });
      $scope.newItemName=""
      $scope.idname=""

   var name=$scope.newName;
   var id=$scope.idname;
   var fs = require('fs');
   var path = require('path');
   var sys = require('sys');
  var exec = require('child_process').exec;

    function puts(error, stdout, stderr) {
     sys.puts(stdout);
     }
     exec("cordova create"+name+id, puts);
    }
     });
      })(angular)

Angular 1.x无法在后端运行(与Node类似),它仅在实际html页面上的实际浏览器中运行时才起作用。使用Angular运行单个js文件没有意义


也就是说,您需要创建index.html,在head或body中包含angular.js文件(来自cdn或本地),然后包含test.js。请注意,由于测试取决于角度,所以必须首先包含角度。然后,只需打开index.html

Angular就是一个前端库。你不能像这样启动一个JS文件。您必须使用html/js创建自己的angular项目,…我创建自己的项目:index.html和test.js。如果一切正常的话。您只需打开index.htmli在控制台中出现以下错误:util.puts:Use console.log而不是util.js:85不推荐的util.js:85(匿名函数)util.js:69puts te.js:34exithandler child_process.js:735EventEmitter.emit events.js:107maybeClose child_process.js:991ChildProcess.\u handle.onexit