我需要Angular / Ionic应用程序的帮助

时间:2016-04-29 19:03:42

标签: javascript angularjs ionic-framework

所以,我只是学习如何做Angular,我也是用Ionic做的。我正在尝试使用visual studio制作我的cordova应用程序的第一页。我已经在我的代码中发现了一堆我已经修复过的错误,但必须有更多,因为它仍然不能像它应该的那样工作。所有帮助将不胜感激。以下是代码的一部分:

var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {

    $scope.darkness = darkness;
    darkness = "Darkness"

    $scope.myFunction = function () {
        $scope.text = text;
        text = "Nothing but darkness and the pain that radiates through your very being."

    }
});
<body>
        <div ng-app="myApp" ng-controller="myCtrl">      
            <p> {{ darkness }} </p>
            <p>  {{ text }} </p>
            <button ng-click="myFunction()">???</button>
        </div>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="scripts/platformOverrides.js"></script>
        <script type="text/javascript" src="scripts/index.js"></script>        
        <script src="scripts/gamefunctions/chapterone.js"></script><script src="scripts/lib/ionic/js/ionic.bundle.js"></script>
</body>

2 个答案:

答案 0 :(得分:1)

首先添加AngularJS

 <script type="text/javascript" src="cordova.js"></script>
<script src="scripts/lib/ionic/js/ionic.bundle.js"></script>
<script type="text/javascript" src="scripts/platformOverrides.js"></script>    
  <script src="scripts/gamefunctions/chapterone.js"></script>
    <script type="text/javascript" src="scripts/index.js"></script>  

定义第一个然后使用

var    darkness = "Darkness";
$scope.darkness = darkness;

var text = "Nothing but darkness and the pain that radiates through your very being.";        
$scope.text = text;

答案 1 :(得分:0)

我看到的一个问题是,在您将其分配给$ scope后,您宣布了黑暗。

所以它应该是:

var darkness = "Darkness";
$scope.darkness = darkness;

同样应该定义文字如下:

 var text = "Nothing but darkness and the pain that radiates through your very being.";
 $scope.text = text;