ng-controller无法正常工作 [英] ng-controller not working

查看:96
本文介绍了ng-controller无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我是棱角分明的新手,



我试图创造一个简单的使用控制器的页面



 <   html  >  
< head >
< title > 控制器示例< / title >
< script src = https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js > < / script >
< script src = js / ControllerExample5.js > < < span class =code-leadattribute> / script >
< / head >
< body >
< div ng-app = ng-controller = studentController >
输入名字:< input type = text ng-model = student.firstName < span class =code-keyword> / >
< br / >
< br / >
输入LastName:< input 类型 = text ng-model = student.lastName / > < br / >
< span class =code-keyword>< br / >
您的全名是:{{student.fullName()}}
< / div >
< span class =code-keyword>< / body >
< / html >







 function studentController($ scope){
$ scope。 student = {
firstName:Nilesh,
lastName:Sukalikar,
fullName:function(){
var studentObject;
studentObject = $ scope.student;
返回studentObject.firstName ++ studentObject.lastName;
}
};
}





当我尝试运行时,没有任何工作,,,请帮助调试此代码..

解决方案

scope){


scope.student = {
firstName:Nilesh,
lastName :Sukalikar,
fullName:function(){
var studentObject;
studentObject =


scope.student;
返回studentObject.firstName ++ studentObject.lastName;
}
};
}





当我尝试运行时,没有任何工作,,,请帮助调试此代码..


Hi ,

I am new to angular js ,

I tried to create one simple page using controller

<html>
<head>
    <title>Controller Example</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js"></script>
    <script src="js/ControllerExample5.js"></script>
</head>
<body>
    <div ng-app="" ng-controller="studentController">
        Enter First Name :<input type="text" ng-model="student.firstName" />
        <br />
        <br />
        Enter LastName:<input type="text" ng-model="student.lastName" /><br />
        <br />
        Your Full Name is : {{student.fullName()}}
    </div>
</body>
</html>




function studentController($scope) {
    $scope.student = {
        firstName: "Nilesh",
        lastName: "Sukalikar",
        fullName: function () {
            var studentObject;
            studentObject = $scope.student;
            return studentObject.firstName + " " + studentObject.lastName;
        }
    };
}



When i try to run this , nothing is working ,,, please help to debug this code ..

解决方案

scope) {


scope.student = { firstName: "Nilesh", lastName: "Sukalikar", fullName: function () { var studentObject; studentObject =


scope.student; return studentObject.firstName + " " + studentObject.lastName; } }; }



When i try to run this , nothing is working ,,, please help to debug this code ..


这篇关于ng-controller无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆