$ scope是正常的函数参数还是特殊的东西?

时间:2015-05-28 15:35:39

标签: angularjs

我是Angular的初学者。我正在看w3schools教程:

http://www.w3schools.com/angular/angular_controllers.asp

我试图改变



app.controller('myCtrl', function($scope) {
    $scope.firstName = "John";
    $scope.lastName = "Doe";
});






app.controller('myCtrl', function(a) {
    a.firstName = "John";
    a.lastName = "Doe";
});




示例停止了工作。看起来$ scope并不仅仅是一个常规的函数参数,但它是什么呢?

1 个答案:

答案 0 :(得分:2)

您可以更改参数名称,但需要使用以下语法表示法:

WITH    StaffHistory
          AS ( SELECT   LocationHistories.UserProfileId ,
                        UserProfiles.FirstName ,
                        UserProfiles.LastName ,
                        LocationHistories.LocationId ,
                        Locations.LocationName ,
                        LocationHistories.LocationHistoryTimeStamp ,
                        PreviousLocationTime = LAG(LocationHistories.LocationHistoryTimeStamp,
                                                   1) OVER ( PARTITION BY LocationHistories.UserProfileId ORDER BY LocationHistories.LocationHistoryTimeStamp ) ,
                        NextLocationTime = LEAD(LocationHistories.LocationHistoryTimeStamp,
                                                1) OVER ( PARTITION BY LocationHistories.UserProfileId ORDER BY LocationHistories.LocationHistoryTimeStamp )
               FROM     LocationHistories
                        INNER JOIN UserProfiles ON LocationHistories.UserProfileId = UserProfiles.Id
                        INNER JOIN Locations ON LocationHistories.LocationId = Locations.Id
               WHERE    LocationTrackingType = 1
             ),
        StaffInRoomTime
          AS ( SELECT   StaffHistory.UserProfileId ,
                        StaffHistory.FirstName ,
                        StaffHistory.LastName ,
                        StaffHistory.LocationId ,
                        StaffHistory.LocationName ,
                        DATEDIFF(SECOND, LocationHistoryTimeStamp,
                                 NextLocationTime) AS TimeSpentInRoom ,
                        StaffHistory.LocationHistoryTimeStamp ,
                        StaffHistory.PreviousLocationTime ,
                        StaffHistory.NextLocationTime
               FROM     StaffHistory
               WHERE    DATEDIFF(SECOND, LocationHistoryTimeStamp,
                                 NextLocationTime) > 120
             ),
        prepareIsland
          AS ( SELECT   * ,
                        CASE WHEN LAG(LocationId) OVER ( PARTITION BY UserProfileId ORDER BY LocationHistoryTimeStamp ) <> LocationId
                             THEN 1
                             ELSE 0
                        END AS prepIsland
               FROM     StaffInRoomTime
             ),
        islands
          AS ( SELECT   * ,
                        SUM(prepIsland) OVER ( ORDER BY UserProfileId , LocationHistoryTimeStamp ) AS Island
               FROM     prepareIsland
             )
    SELECT  island ,
            UserProfileId ,
            FirstName ,
            LastName ,
            LocationId ,
            LocationName ,
            SUM(TimeSpentInRoom) TimeSpentInRoom ,
            MIN(LocationHistoryTimeStamp) LocationHistoryTimeStamp ,
            MIN(PreviousLocationTime) PreviousLocationTime ,
            MAX(NextLocationTime) NextLocationTime
    FROM    islands
    GROUP BY island ,
            UserProfileId ,
            FirstName ,
            LastName ,
            LocationId ,
            LocationName
    ORDER BY UserProfileId ,
            LocationHistoryTimeStamp

看看http://naddame.blogspot.in/2014/12/spring-roo-mvc-integration-for-swagger.html