Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.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
Javascript angular js中的自定义指令_Javascript_Html_Angularjs - Fatal编程技术网

Javascript angular js中的自定义指令

Javascript angular js中的自定义指令,javascript,html,angularjs,Javascript,Html,Angularjs,为什么angular js中的这个自定义指令对我不起作用。我只获取用户:但没有获取我在userinfo自定义指令标记中传递的用户的名称 用户指令\u index.html文件: <html ng-app='app' > <head> </head> <title> User Directive </title> <body > <div> <div ng-model='firstcontroller'&g

为什么angular js中的这个自定义指令对我不起作用。我只获取用户:但没有获取我在userinfo自定义指令标记中传递的用户的名称

用户指令\u index.html文件:

<html ng-app='app' >
<head>
</head>
<title>
User Directive
</title>
<body >

<div>
<div ng-model='firstcontroller'>
<userinfo user="Raj"></userinfo>
</br>
<userinfo user="Sudhir"></userinfo>
</div>
</div>
<script type="text/javascript" src="../js/angular.min.js"></script>
<script src='app.js'></script>
</body>
</html>

我从以下位置获得此代码:

您必须在此处更改指令


非常感谢。伙计。我能收到你的电子邮件ID吗?这样我就可以直接把疑虑放在那边了。你似乎在这个框架里有很多经验。我真的迫切需要一些指导来帮助我在角JS。@ RayJeHWAR,如果这个答案帮助你解决了你的问题,请考虑。
var app1=angular.module('app',[]);
app1.controller('firstcontroller',function($scope){
$scope.Raj={};
$scope.Raj.firstname='Rajeshwar';
$scope.Raj.lastname='Bose';
$scope.Sudhir={};
$scope.Sudhir.firstname='Sudhir';
$scope.Sudhir.lastname='Ranjan';

});

app1.directive('userinfo',function(){
var directive={};

directive.restrict='E';
directive.template='User:{{user.firstname}} {{user.lastname}}';

directive.scope={
user:"= user"
};

return directive;
});
<div ng-model='firstcontroller'>
        ^^^^^
<div ng-controller='firstcontroller'>