如果我保持这些脚本代码在html文件没有错误发生,但如果我保持在另一个单独的脚本文件,是的,错误发生

If i keep those script code in the html file no error occurs, But if i kept in another individual script file, yup error occurs

本文关键字:如果 脚本 文件 单独 另一个 是的 错误 有错误 html 代码      更新时间:2023-09-26
<!-- HTML FILE-->
Gender      :   <label ng-repeat="option in gend">
   <input type="radio" ng-model="$parent.option" ng-value="option">{{option.I}}{{option.O}}</label></br></br> 

<!--Module-->
angular.module("appy", []);

<!-- Controller-->
appy.controller('Cont',function($scope){
    $scope.user='';
    $scope.pas='';
    $scope.selected='male';
    $scope.gend=['male','female'];
    $scope.addr='';
    $scope.emailid='';
    $scope.coun=[ I='India',O='Other'];
    $scope.ph='';
    $scope.pincode='';
    $scope.movedude = function() {
        window.location = "Redir.html";
    }
});

appy或你的应用名,只存在于Angular中。您的浏览器不知道它的存在。所以你应该把你的控制器和模块定义链接起来,或者把你的模块赋值给一个变量,然后在整个程序中使用这个变量。这是不正确的:

angular.module("appy", []);  
appy.controller('Cont',function($scope){});

试试链接:

angular.module("appy", [])  
.controller('Cont',function($scope){});

或使用JS变量:

var app = angular.module("appy", []);  
app.controller('Cont',function($scope){});