Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 Angular未能在初始页面加载时实例化模块_Angularjs - Fatal编程技术网

Angularjs Angular未能在初始页面加载时实例化模块

Angularjs Angular未能在初始页面加载时实例化模块,angularjs,Angularjs,我有一个Angular模块,无论出于什么原因,它都不会在初始页面加载时实例化,有时还会在刷新时随机实例化。只是想让您知道angular.js没有加载到标记中,因为我无法控制它,所以我必须在主体中调用脚本(代码基本上放在CMS模板中) 这就是代码当前的样子,我将实际脚本放在一个标记中,以消除可能由于任何原因没有加载包含模块的js文件的可能性 <script src="/bizcontent/minuteclinic/desktop/general/angular.js"></sc

我有一个Angular模块,无论出于什么原因,它都不会在初始页面加载时实例化,有时还会在刷新时随机实例化。只是想让您知道angular.js没有加载到
标记中,因为我无法控制它,所以我必须在主体中调用脚本(代码基本上放在CMS模板中)

这就是代码当前的样子,我将实际脚本放在一个
标记中,以消除可能由于任何原因没有加载包含模块的js文件的可能性

<script src="/bizcontent/minuteclinic/desktop/general/angular.js"></script>
<script>
var app = angular.module('exampleApp', []);
  app.controller('MainCtrl', function($scope) {
    $scope.field = {
      value: null
    };
    $scope.field2 = {
      value2: null
    };
    $scope.field3 = {
      value3: null
    };
    $scope.field4 = {
      value4: null
    };
    $scope.field5 = {
      value5: null
    };
    $scope.field6 = {
      value6: null
    };
    $scope.field7 = {
      value7: null
    };
    $scope.field8 = {
      value8: null
    };
    $scope.field9 = {
      value9: null
    };
    $scope.field10 = {
      value10: null
    };

    $scope.question = {
      answers: [
        {title: "A (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "B (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers2: [
        {title: "C (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "D (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers3: [
        {title: "E (correct)",   correct: true, answer: "This is the incorrect answer"},
        {title: "F (incorrect)", correct: false, answer: "Pollen is #1"}
      ],
      answers4: [
        {title: "G (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "H (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers5: [
        {title: "I (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "J (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers6: [
        {title: "I (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "J (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers7: [
        {title: "I (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "J (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers8: [
        {title: "I (correct)",   correct: true, answer: "This is the incorrect answer"},
        {title: "J (incorrect)", correct: false, answer: "Yes, they are."}
      ],
      answers9: [
        {title: "I (correct)",   correct: true, answer: "This is the correct answer"},
        {title: "J (incorrect)", correct: false, answer: "This is the incorrect answer"}
      ],
      answers10: [
        {title: "I (correct)",   correct: true, answer: "This is the incorrect answer"},
        {title: "J (incorrect)", correct: false, answer: "Hay fever sufferers should know the pollen count forcast before planning any outdoor activities."}
      ]
    };
    $scope.select = function(field, answer) {
      if (answer.checked) {
        field.value = answer.answer;
        field.value_correct = answer.correct
      } else {
        field.value = null;
      }
    };

    $scope.updateSelection = function(position, entities) {
      angular.forEach(entities, function(answer, index) {
        if (position != index) 
          answer.checked = false;
      });
    }

  });
</script>
<div ng-app="exampleApp">

var app=angular.module('exampleApp',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.field={
值:null
};
$scope.field2={
值2:null
};
$scope.field3={
值3:空
};
$scope.field4={
值4:null
};
$scope.field5={
值5:空
};
$scope.field6={
值6:null
};
$scope.field7={
值7:空
};
$scope.field8={
值8:null
};
$scope.field9={
值9:null
};
$scope.field10={
值10:空
};
$scope.question={
答复:[
{标题:“A(正确)”,正确:正确,回答:“这是正确的答案”},
{标题:“B(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复2:[
{标题:“C(正确)”,正确:正确,回答:“这是正确的答案”},
{标题:“D(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复3:[
{标题:“E(正确)”,正确:正确,回答:“这是错误的答案”},
{标题:“F(不正确)”,正确:错误,回答:“花粉是#1”}
],
答复4:[
{标题:“G(正确)”,正确:正确,回答:“这是正确的答案”},
{标题:“H(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复5:[
{title:“I(correct)”,correct:true,答案:“这是正确的答案”},
{标题:“J(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复6:[
{title:“I(correct)”,correct:true,答案:“这是正确的答案”},
{标题:“J(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复7:[
{title:“I(correct)”,correct:true,答案:“这是正确的答案”},
{标题:“J(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复8:[
{标题:“我(正确)”,正确:正确,回答:“这是错误的答案”},
{标题:“J(不正确)”,正确:错误,回答:“是的,他们是。”
],
答复9:[
{title:“I(correct)”,correct:true,答案:“这是正确的答案”},
{标题:“J(不正确)”,正确:错误,回答:“这是不正确的答案”}
],
答复10:[
{标题:“我(正确)”,正确:正确,回答:“这是错误的答案”},
{标题:“J(不正确)”,正确:错误,回答:“花粉热患者在计划任何户外活动之前应该知道花粉数量预测。”
]
};
$scope.select=函数(字段,答案){
如果(回答。勾选){
field.value=answer.answer;
field.value\u correct=answer.correct
}否则{
field.value=null;
}
};
$scope.updateSelection=函数(位置、实体){
angular.forEach(实体、函数(答案、索引){
如果(位置!=索引)
答案:checked=false;
});
}
});
最后,你会看到应用程序被调用的位置(我对Angular还很陌生,所以如果我使用了不正确的术语,我会提前道歉)

当模块不能正常工作时,我得到错误:$injector:nomod 模块不可用错误,如下所示


模块“exampleApp”不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。

未加载角度文件,请在浏览器中检查网络。看看我用了你的文件内容,它的作品检查标签。“/bizcontent/minuteclinic/desktop/general/”对于angular脚本来说似乎是个奇怪的地方。@Vivek:Remove@jbrown不幸的是,我需要将它放在该页面的目录结构中。我正在考虑改用jQuery,这一点太随意了。@ArunShinde他没有在单独的js文件中编写。你可以找到解决方案。