简体   繁体   English

为什么这个AngularJs代码不起作用,因为我也尝试运行一些完美的代码,但是我的浏览器也没有运行它们

[英]why this AngularJs code is not working as i tried to run some perfect codes too but my browser doesn't run them also

i'm running it using XAMPP but it's not working and showing output of {{"Hello"+"you"}} rather than Hello you 我正在使用XAMPP运行它,但无法正常工作,并且显示了{{“ Hello” +“ you”}}而不是“ Hello you”的输出

<!DOCTYPE HTML>
<html>
   <head ng-app="store">
   <link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
   </head>
   <body>
      <script  type="text/javascript" src="angular.min.js">
      </script>
      <script >
        var abc=angular.module('store',[]);
      </script> 
      <p>
        {{"Hello"+"you"}}
      </p>
   </body>
</html>

First, you should create a controller in your JS , then you use it in your view. 首先,您应该在JS中创建一个controller ,然后在视图中使用它。

You can do it setting the ng-controller directive , as below: 您可以通过设置ng-controller 指令来做到这一点,如下所示:

 <!DOCTYPE html> <html ng-app="store"> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script> <script> angular.module('store', []) .controller('storeCtrl', function($scope) { }); </script> </head> <body ng-controller="storeCtrl"> <p> {{"Hello"+"you"}} </p> </body> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM